Suppose content of my first file:
first line
second line
third line
How can i insert text between "first line" & "second Iline"
Any help?????/
Suppose content of my first file:
first line
second line
third line
How can i insert text between "first line" & "second Iline"
Any help?????/
Alternative in Python:
#!/usr/bin/python
data = open("file").readlines()
data.insert(1,'inserted line\n')
print ''.join(data)
Output:
first line
inserted line
second line
third line
sed "/first line/i\\
hi buddy\\
how r u ?\\
Gud morning" file
or if you want to add contents from a file use this
sed "/first line/r secondfile" file
------------------------------------------
--------------------------------
if i have a file of 1000 lines.....
how can I give set a particular in the sed command....this is ok for a file with few lines...hope u understand the concern.....
text deleted..
Sorry.. Understood the requirement wrongly
Can you explain with example?
Simply:
sed '2i Hello' file
This will return
first line
Hello
second line
third line
use ex editor
ex $filename <<!
$n
i
line1
line2
.
:w
!
Thanks
Mark.