How can I insert some text in specific lines of a file? What is the simplest method that I can use? (bash
, sed
, awk
?)
What I want to do might be simple, but I don't know where I should start. It takes too much time for me to try to do this manually (I have a lot of files that I have to change for Excel/Calc later use).
Here is my input file example:
4.06
4.05
5.04
4.06
34.50
56.06
45.33
36.44
And I want something like this (insert text before line 1 and 5):
Exp1
4.06
4.05
5.04
4.06
Exp2
34.50
56.06
45.33
36.44
How can I do this?
ed
binge :v ) is how to do it with ed:printf '%s\n' 1 i Exp1 . 5 i Exp2 . w q | ed file.txt
. I'm keeping this as a comment rather than an answer because I don't think anyone will actually use this lol. – evilsoup Nov 02 '13 at 20:11