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

  Opatch reports 'Cyclic Dependency Detected' error when patching ODI   Issue: When applying a Patch Set Update (PSU) to WebLogic Se...