I need to write a bash script that copies the files to dir2 that match the character count in their filename with a given int value given as an argument to the script. I've tried to do something but I cannot manage to get the files copied at all.
read number
list=`for file in *; do echo -n "$file" | wc -m; done`
for file in $list
do
if [ $file -eq $number ]
then
cp file dir2
fi
done