I need to add some words at the end of each line of a text file. How can I do this with a Bash script?
Example: add the word done
at the end of each line:
line1 abcdefg done
line2 abcdefg done
line3 abcdeft done
Use awk:
awk 'NF{print $0 " done"}' inFile
OR sed with inline flag:
sed -i.bak '!/[^[:blank:]]/s/$/ done/' inFile
Did I read vim?
Content of script.vim
:
set backup
g/^/ normal A done
normal ZZ
Run it like:
vim -S script.vim infile
It will modify the file in-place creating a backup with ~
suffix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With