![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| insert a line after specific line | namishtiwari | Shell Programming and Scripting | 8 | 05-21-2008 11:16 AM |
| how to insert a line number on every line | mopimp | UNIX for Dummies Questions & Answers | 3 | 03-25-2006 10:35 AM |
| insert word in each line of a file | atticus | Shell Programming and Scripting | 7 | 03-22-2006 11:15 PM |
| insert a line in a file | RishiPahuja | Shell Programming and Scripting | 7 | 06-22-2005 12:47 AM |
| Insert a line as the first line into a very huge file | shriek | UNIX for Advanced & Expert Users | 3 | 03-08-2005 10:22 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Insert a line
Hi Guys!!!!!!!!!!
I have an input file say abcdef 123456 aaaaaa i need to insert a line say "bbbbbb" between abcdef and 123456 so that my o/p is abcdef bbbbbb 123456 aaaaaa How to achieve it? Thanks in advance |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
sed '/abcdef/a \bbbbb' your_file > new_file |
|
#3
|
|||
|
|||
|
same file dosen't get updated.
when i tried the following one:- sed '/abcdef/a \bbbbb' your_file > your_file. the contents of your_file got deleted. why it was so. |
|
#4
|
|||
|
|||
|
You cannot change the contents of the file using sed but the output could be redirected to a new file. If you are going to redirect the same to the input file then it would result in a empty input file.
|
|
#5
|
|||
|
|||
|
Quote:
using the " -i " option but that is available only as GNU sed option. Code:
sed -i 's/search/replace/g' inputfile |
|
#6
|
|||
|
|||
|
Thanks Guys!!!!!!!!!!!!!!!
But have a doubt .. If suppose my input contains space... For ex: I/p File: abc def aaaaa abc def bbbbb No i want to add the pattern 12345 after abc def so that my o/p file wil be abc def 12345 abc def bbbbb |
|||
| Google The UNIX and Linux Forums |