how to add tab(multiple spaces) at each end of a text file using Unix -


i new unix commands. ask if adding tab or should multiple spaces right after @ end of each line in unix possible?

to give clearer view of talking about, supposed have text file named wow.txt , contains: (note wow.txt product script run. automatically made a script)

wow

wow2

wow3

wow4

and want add tabs @ each end of line. how want output.

wow1 kerv

wow2 kerv

wow3 kerv

wow4 kerv

or

wow1, kerv

wow2, kerv

wow3, kerv

wow4, kerv

thats want output. want add word 'kerv' @ each end of line on text file. please me???

a reply appreciated. thanks!!!!

you can use following awk script. awk '{printf("%s \t\n", $0)}' your_file.txt > new_file.txt

please note \t adds tabs. if want multiple tabs, can \t\t , \n newline character

if want add kerv or whatever, add appropriately, e.g. "%s, \t kerv : \t\t\n if not want old file, execute rm your_file.txt

edit: use following not append link if blank--

awk '{ if (nf > 0) { printf("%s \t\n", $0)} }' your_file.txt > new_file.txt

edit: if want retain blank lines, not append anything

awk '{ if (nf > 0) {printf("%s \t\n", $0)} else {print $0} }' your_file.txt > new_file.txt


Comments