lets say i have a file named ex1 which contain an essay.
(a) delete the word "benefit" from the file
(b) delete the last 6 characters on each line
for the first problem i entered :g/benefit/d but it deletes the whole line
please help
lets say i have a file named ex1 which contain an essay.
(a) delete the word "benefit" from the file
(b) delete the last 6 characters on each line
for the first problem i entered :g/benefit/d but it deletes the whole line
please help
Hope this is not homework; there are rules for that!
:1,$s/\<benefit\>//g
:1,$s/.\{6\}$//
Thank you DGPickett
I usually do surgery with sed from one file to another, so mistakes are not an issue. Interactive vi's : is ex, a line editor, and sed is streaming ex, sorta, with much less overhead.
sed '
s/\<benefit\>//g
s/.\{6\}$//
' file_in >file_out