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
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
sed '/abcdef/a \bbbbb' your_file > new_file
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.
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.
you can edit the same file with sed
using the " -i " option but that is available only as GNU sed option.
sed -i 's/search/replace/g' inputfile
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