Skip to content

Instantly share code, notes, and snippets.

@nsahoo
Last active January 17, 2020 13:50
Show Gist options
  • Save nsahoo/4b2e7923e727ad6c8c66f33be375357e to your computer and use it in GitHub Desktop.
Save nsahoo/4b2e7923e727ad6c8c66f33be375357e to your computer and use it in GitHub Desktop.
insert_a_string_to_a_file_at_each_line
# insert a string at end of each line in a file, for example:
perl -i -pe 's/$/ STRING1 /' test.list
# insert a string at beginning of each line in a file, for example:
perl -i -pe 's/^/ STRING2 /' test.list
# doing both at a time
perl -i -pe 's/^/ STRING1 /; s/$/ STRING2 /' test.list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment