How to Remove Duplicate lines from Unix vi Editor file

advertisements

_____________________________________________________________________________________________________________________

The Eucharistic Miracles of the World
Sometimes we have the requirement for removing the duplicate lines from the text file. For that we can easily use vi to remove the duplicate lines instead of using any other scripts or tools. Here are the options to remove the duplicate lines from the vi file.


Option1
Open the vi file and in command mode (press esc) give the command :sort u
The above command will sort the file which will give the file with duplicate lines closer. Now you can remove the duplicate lines.

Option2
1G #### Go to first line of the file
!Gsort ## Sort the file from the first line
1G #### Again go to first line
!Guniq ## Remove duplicate with uniq command.

_____________________________________________________________________________________________________________________

Website Stats

0 comments:

Post a Comment

Labels

Oracle (629) Script (86) General (77) Unix (47) Blog (23) Technology (19) gadget (6) games (6) Business (3) OCI (3) SQL* Loader (3) Datapump (2)
 

acehints.com Copyright 2011-23 All Rights Reserved | Site Map | Contact | Disclaimer