I'm trying to compare the first character of each line of a buttload of files with the format filename.number.ext where number is a 4-digit number (0001, 0015, 5403, etc). My script goes like this:
n=$1
awk '{print $1}' filename.0001.ext > temp1.dat
for i in {0002..$n}
do
echo $i
awk '{print $1}' filename.$i.ext > temp.dat
diff temp1.dat temp.dat
done
This works fine if, instead of an input, I use a fixed value for the number of files, like so:
awk '{print $1}' filename.0001.ext > temp1.dat
for i in {0002..0345}
do
echo $i
awk '{print $1}' filename.$i.ext > temp.dat
diff temp1.dat temp.dat
done
However, with the first version if I input 0345 for example, the shell returns
$ myscript.sh 0345
{0002..0345}
awk: cannot open filename.{0002..0345}.ext (No such file or directory)
I'm a little lost here. I insist on using {0002..0345}
over seq
because all the file numbers have a fixed length of 4.