Re: process multiple files
Randy wrote:
> I am new to unix shell.
>
> I need to add a single line to the beginning of multiple ( 100's )
> files. Can I automate this through shell scripting and if so, can
> anyone point me to a newbie resource.
>
> Thanx Randy
>
with GNU tools use:
for FILE in *
do
echo "$LINE" | cat - "$FILE" > "$FILE.NEW"
mv "$FILE.NEW" "$FILE"
done
or use
find -type f -print0 | xargs -r0 sed -i "0i$LINE"
look for
man 1 bash
echo
for
man 1 cat
man 1 mv
info find
man 1 xargs
info sed
Regards,
Steffen Schuler
|