top of page
Writer's pictureJatin Madaan

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


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 ^ :





17 views0 comments

Comments


bottom of page