INSTALLATION DOCUMENTS BY RAVI

Thursday, May 11, 2017

sed command to add a line in nth place of a file in linux

Command to add a string in nth line of a file:

sed -i '8i string to add' filename

8: stands for 8th line in file
i: insert

The above command will add the string in 8th line of all the file.

Command to add a string in nth line of all files in a directory:

sed -i '8i string to add' *

The above command will add the string in 8th line of all the files in the directory.


sed -i '8i string to add' filename*.txt

The above command will add the string in 8th line of all the files with extension .txt in the directory.

No comments:

Post a Comment

Loading xml file data to oracle table using python

Sample xml file (test.xml): <?xml version="1.0"?> <data>     <customer name="Ravi" >     ...