vi editor: remove lines longer than 40 characters

when i was working with mail address , one stage i had to export the contact list to a file and found there is junk mail address which obviously long lines likeĀ 013f8be66f33ce4b6dc28e505e56ddda@m.facebook.com

 

so i found a way to remove all lines longer than 40 characters with the most powerful VI editor

 

open your file in vi

 

# vim filename

and type this

:g/.\{40,\}/d

whala! you will see a message – something like this

324 fewer lines