0

I need a script that add a particular character to the end of each line . I am using the command
sed 's/$/ foo/' r.txt

It adds foo to end of each line in the file r.txt and displays in my terminal . What do i need to do if i want to save this existing file with this new record appended after the end of each line .

user1483747
  • 63
  • 2
  • 3
  • 5

1 Answers1

13

To save to a new file:

sed 's/$/ foo/' r.txt > newfile.txt

To edit in place

sed -i 's/$/ foo/' r.txt
David C. Rankin
  • 81,885
  • 6
  • 58
  • 85