- #1
Chrisas
- 152
- 0
I get a bunch of input files from a Windows data recorder. It produces file names with spaces everywhere. I am trying to write a script to process these files. This process involves several steps with multiple output files generated. I want to strip off the extension of the input file and use the name with different extensions for the output files.
Example: I can manually type the file names with ' ' and this works
for FILE in 'file 1' 'file 2' 'file 3'
do
stuff1 < ${FILE}.in > ${FILE}.out1
stuff2 < ${FILE}.in > ${FILE}.out2
done
Example: I try to automatically get filenames
for FILE in `ls -1 *.in | awk -F. '{ print $1; }'`
stuff1 < ${FILE}.in > ${FILE}.out1
stuff2 < ${FILE}.in > ${FILE}.out2
done
This fails because FILE contains file 1 file 2 file 3 and so the loop uses just "file" not "file 1".
Example: I tried to use awk to add ' ' around the file names, something like:
for FILE in `ls -1 *.in | awk -F. '{ print "\'", $1, "\'"; }'`
But no matter what I try I get a syntax failure.
Any ideas?
Thanks.
Example: I can manually type the file names with ' ' and this works
for FILE in 'file 1' 'file 2' 'file 3'
do
stuff1 < ${FILE}.in > ${FILE}.out1
stuff2 < ${FILE}.in > ${FILE}.out2
done
Example: I try to automatically get filenames
for FILE in `ls -1 *.in | awk -F. '{ print $1; }'`
stuff1 < ${FILE}.in > ${FILE}.out1
stuff2 < ${FILE}.in > ${FILE}.out2
done
This fails because FILE contains file 1 file 2 file 3 and so the loop uses just "file" not "file 1".
Example: I tried to use awk to add ' ' around the file names, something like:
for FILE in `ls -1 *.in | awk -F. '{ print "\'", $1, "\'"; }'`
But no matter what I try I get a syntax failure.
Any ideas?
Thanks.