This post indicates how to insert text in specific lines of a file.
Instead of inserting text I would like to inseart a repetition of a number. For example this series: 2 2 2 2 2 2 2 ... (100 times)
This post indicates how to insert text in specific lines of a file.
Instead of inserting text I would like to inseart a repetition of a number. For example this series: 2 2 2 2 2 2 2 ... (100 times)
Generate the text you'd like inserted:
$ perl -e 'print "2 " x 99, "2\n"' >insert
Insert it into the file (on line 4 in this example):
$ cat file
The
Dog
Is
Here
$ sed '3r insert' file >file.tmp && mv file.tmp file
$ cat file
The
Dog
Is
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
Here
The sed editing command r ("read") will append the contents of a given file on the next line.