Bussiere
Bussiere

Reputation: 1154

How to insert a text at the beginning of multiple file?

i have multiple file like xaa xab xac and i would like to insert the same line in the beginning of all :

here is the command that i found for one :

sed -i '1s/^/id,compressedString,url,categorie,date,name\n /' xad

and i would like to apply it on my multiple files like x*

Thanks and regards

Upvotes: 1

Views: 853

Answers (2)

koalo
koalo

Reputation: 2313

Just use a loop

for f in x*; do
   sed -i '1s/^/id,compressedString,url,categorie,date,name\n /' "$f"
done

Upvotes: 3

SLePort
SLePort

Reputation: 15461

If files are in same directory, try this:

sed -i '1s/^/id,compressedString,url,categorie,date,name\n /' x*

Upvotes: 2

Related Questions