33
votes

I would like to add character A at the end of each line in a text file. How can I do this with awk?

1AAB
VBNM
JHTF
2SDA

Desired output

1AABA
VBNMA
JHTFA
2SDAA
1
You can do this pretty easily with sed - sed -i 's/$/A/' file.txt - squiguy
Be careful to -i flag, it overrides file.txt in-place - EnthusiastiC
You can use this sed -e '1 s/$/400/' -e '2 s/$/401/' -e '3 s/$/402/' -e '4 s/$/403/' file.txt to add at end of each line a specified character (e.g., here I used numbers 400-403). The number 1,2, and 3 reflects the line index. - EnthusiastiC

1 Answers

51
votes

this may do the job for you

awk '{print $0"A"}' yourFile