A shell script with a "here document" will handle this nicely:
#!/bin/bash
for NAME in t?
do
ex -s $NAME << END_EDITS
1s/TestRelation/$NAME/
w!
q
END_EDITS
done
Not knowing what your files are named, I chose "t1", "t2", "t3", etc as file names. You will have to generate file names as appropriate.
The "for" loop gives shell variable NAME
the value of a file's name each time through the loop. The bash
instance executing the above script calls the ex
editor on each file name, and gives it some input lines. The 1s/TestRelation/$NAME/
ex command gets expanded by the bash
instance, which substitutes a file's name for the "$NAME" part.
You have to have the token that ends the "here document" (END_EDITS
in this case) at the beginning of a line, no white space in front.
find . -name "*.bak" -delete
to delete all of the.bak
files. – Adam_G Feb 08 '15 at 16:09