Mangoski
Mangoski

Reputation: 2119

Append new line in all files of the folder

I have 300 files in a folder. I have to append one new line at the end of all files in a folder.

How can i achieve it using grep.

I tried the following command but its not working

sed 's/$/\n/' /Path/filename.txt

Upvotes: 12

Views: 13797

Answers (1)

fedorqui
fedorqui

Reputation: 289835

Just say echo "" >> file. This will append a new line at the end of file.

To do it in all the files in the folder:

for file in *
do
    echo "" >> "$file"
done

From the comments, in your case you have to say:

for file in /path/*.txt
do
    echo "" >> "$file"
done

Upvotes: 25

Related Questions