1834163 Members
2482 Online
110064 Solutions
New Discussion

About line editing

 
SOLVED
Go to solution
Stoicho Valkov
Advisor

About line editing

For script purpuse, how can I take a line number and to work with exact line?
Is there simple command which works with lines of the file?
For example I want to take line 3 from file1 and to put it between 6 and 7 of file2?
Text editor
3 REPLIES 3
Mark Grant
Honored Contributor

Re: About line editing

There are no commands to do what you want here. I would suggest a script to do it.
Never preceed any demonstration with anything more predictive than "watch this"
Graham Cameron_1
Honored Contributor

Re: About line editing

To get line 3 from file 1
--
awk '(NF==3){print}' file1
--
to get line 3 from file 1 and save it in an environment variable:
--
L3=$(awk '(NR==3){print}' file1)
--
To put this before line 7 of file2 and send the result to fil33
--
awk -v L=$L3 '(NR==7) {print L} {print}' file2 > file3
--
You get the idea.
-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
T G Manikandan
Honored Contributor
Solution

Re: About line editing

#head -6 ;sed -n '3p' ;tail +7