I am quite new at bash programming. Here is my full problem: Write a shell script that takes pairs of parameters (a filename and a number n) and for each pair will verify if the size of the file equals the number n.
Here is what i tried to do:
#!/bin/bash
for i in {$1..${@:(-2):1}..2}
do
for j in {$2..${@: -1}..2}
do
if [$(stat -c%s "$i") -eq $j ]
then
echo $i is $j
else
echo $i is NOT $j
fi
done
done
I am trying to put into variable i the filename from each pair and in j the number n from each pair. I am then comparing the size of my file with j (the number n). I'm not sure what i;m doing wrong, i did some researsh and tested parts of my code to see if it works but something is wrong with my for statement because it kind of prints the whole . Output:
[: -eq: unary operator expected
{c.s..c.s..2} is NOT {12..12..2}
Thank you.