sed question

a directory has 1000 files
is there a easy way to add a line before every line in every file?

foe example

if line is

{i am a line}

the output would be

{added new line}
{i am a line}

in every file

something like
sed -e 's/{ 'key' : 'value'}
/$/' -i for_every_file
Who is Participating?
farzanjConnect With a Mentor Commented:

perl -pe -i 's/^/{added new line}\n/' filename

Open in new window

sed -i 's/^/{added new line}\n/' filename

Open in new window

All you need to do is to make a loop through all the files and within the loop add one of the above lines
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.