I need to create an empty file using a shell script. The filename will be determined by examining all the files in a directory matching a pattern, say TEST.*
, and appending _END
to it so that the new file might look like TEST.2011_END
. Let the current directory be $DIR
. So I tried:
for file in $DIR/TEST.*
do
touch $file_END
done
This gives an error. I also tried replacing touch $file_END
with:
filename=$file_END
touch $filename
but with no luck. What should I do?
Best Answer
The syntax would be:
or in your code
The
"
quotes are not necessary as long as$file
does not have any whitespace or globbing character in it.