Quote:
Originally Posted by noir911
I want to append to line number 45 of a file. Currently I am doing echo "something" >> file which puts "something" at the end of the file. But I would like to echo to, say, line number 33.
Thanks for any help.
|
sounds like homework, soooo....
what you need to do is separate the file into parts, output part 1 to a file, then the line to insert, then part 2 to the file.
head and tail can help, i.e. "head -n 10 myfile" will print out the first 10 lines of "myfile". "tail -n 10 myfile" will print out the last 10 lines of "myfile". "wc -l myfile" will count the number of lines in "myfile".
Hopefully that's enough to get you going.