advertisements
_____________________________________________________________________________________________________________________
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.
_____________________________________________________________________________________________________________________
0 comments:
Post a Comment