CyberKeeda In Social Media

SED to add specific string for the very much first line, beginning of a file.



Sometimes you might have required to add just a specific string at the beginning of a file.

so don't worry our friend SED will help us out.

Example


I have a file named as myweekdays.txt that contains all the weekdays as.

[root@cyberkeeda ~]# cat myweekday.txt

Sun
Mon
Tue
Thu
Fri
Sat

Now i need to simlpy add Weekdays at the beginning of the same file to look it as

[root@cyberkeeda ~]# cat myweekday.txt

Weekdays
Sun
Mon
Tue
Thu
Fri
Sat

SED Command to do.

Check and verify the output using 

[root@cyberkeeda ~]# sed -e ' 1iWeekdays\' imyweekday.txt

Write the orignal file using -i parameter

 [root@cyberkeeda ~]# sed -i -e ' 1iWeekdays\' imyweekday.txt

3 comments:

Designed By Jackuna