Adding characters to beginning or end of every line in a file

Writing by on Tuesday, 28 of July , 2015 at 10:34 pm

You can use awk:

awk ‘{print “Begin : ” $0 ” \”End\”.”}’ file.txt

Or you could use sed:

sed ‘s/^/ Begin : /g’ file.txt
sed ‘s/$/ “End”./g’ file.txt

Leave a comment

Category: Linux

No Comments

No comments yet.

Leave a comment

You must be logged in to post a comment.

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.