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
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