I have a file which has the number of .pdfs in my folder. I assign this number to a variable, fileNum like so:
fileNum=$(ls -l *.pdf | wc -l)
echo $fileNum returns this number without any problem.
Now I need to use fileNum in a for loop and I am having problems with it.
My for loop is:
for i in {1..$fileNum} do var=$(awk 'NR=='$i 'pdfs.file') gs \ -sOutputFile="exgs_"$var \ -sDEVICE=pdfwrite \ -sColorConversionStrategy=Gray \ -dProcessColorModel=/DeviceGray \ -dCompatibilityLevel=1.4 \ -dNOPAUSE \ -dBATCH \ $var done
The $ at the beginning of fileNum gives me an error message which is:
awk: line 1: syntax error at or near {
Things are fine when I actually use the number itself (which in this case is 17).
Obviously, awk doesn't like this because of ... something.... I don't know what. What should I do about this?
I tried other forms such as $(fileNum) and filenum with the single quotes around it.
Is it something to do with strings?
echo 'NR=='$i