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

Perfect order of ODI export and import

  Smart Export / Import is the recommended way to achieve such a migration. This is the easiest way to make sure all the dependencies are ta...