Reputation: 127
i need to add a line of text at the begininng of each file (commands text) in a directoy (not all of them).
is there any way to do so ?
the line would be something like ID DATE NAME with spaces inbetween for example : a12345 20190418 tarik
(the files do not contain .txt at the end names are more like .abcd_1452a)
Upvotes: 0
Views: 61
Reputation: 7235
You can use script like this (file oneline_file
contain the line you want to add) :
echo "a12345 20190418 tarik">oneline_file
for i in *.abcd_1452
do
cat oneline_file "$i" >/tmp/"$i"
mv /tmp/"$i" "$i"
done
Upvotes: 1