I have many files within the same subdirectory that looks like:
10 A
11 T
12 A
13 C
15 A
i.e. two columns, where the first line always begins with the number 10.
I would simply like to add lines 1-9 to the beginning of each file i.e.
1
2
3
4
5
6
7
8
9
10 A
11 T
12 A
13 C
15 A
I don't care about appending the second column.
I know I could do
sed -i '1i1' FILE
to add a first line, but do I have to type this command out for each additional line I want to add?
Try
seq 1 9 | cat - file.in > file.out
Where file.in
is the input file you mentioned, and file.out
is the name of the desired output file.
Or, even shorter (thanks @william-pursell):
{ seq 1 9; cat file.in; } > file.out
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With