top of page

Sed command to add characters in starting and end of each line of a file in Unix.

  • Writer: Jatin Madaan
    Jatin Madaan
  • Apr 3, 2019
  • 1 min read

Let's say we have a file with few lines and we want to add a string in starting and end of each line , this can be done via 2 sed commands as follows :



The above command will add "." (dot ) at end of each line in a file . Here file is not changed just output is displayed , to make changes in-place use

sed -i [command] [file_name]


$ in command after s/ means at end of each line .


Similarly to add in starting of each line we use ^ :





Comentarios


  • linkedin

©2019 by Jatinmadaan

bottom of page