shell - How to add text at the end of each line in unix -
i doing text processing operations , able file this
india sudan japan france now want add comment in above file in final file should
india | country sudan | country japan | country france | country like same comment across whole file. how do this?
there many ways:
sed: replace $ (end of line) given text.
$ sed 's/$/ | country/' file india | country sudan | country japan | country france | country awk: print line plus given text.
$ awk '{print $0, "| country"}' file india | country sudan | country japan | country france | country finally, in pure bash: read line line , print given text. note discouraged explained in why using shell loop process text considered bad practice?
$ while ifs= read -r line; echo "$line | country"; done < file india | country sudan | country japan | country france | country
Comments
Post a Comment