need help with bash command
Hello,
Can you help me with a bash command?
I a directory, I want to extract with a command line for jpg name files.
I have a lot of:
icon_3620_0_1.jpg
icon_3616_0_1.jpg
icon_3563_0_1.jpg
I want to extract the number betwen icon_*_0_1.jpg AND I want to use
the entire filename too in the same command.
The goal is to create a directory called 3620 and move the
icon_3620_0_1.jpg file into this directory.
So, I did like this for test:
# for a in `ls | sed -e s'/_/ /g' | awk '{print $2}'`; do echo
icon_$a_0_1.jpg; done
I hope it should give me:
icon_3620_0_1.jpg
icon_3616_0_1.jpg
icon_3563_0_1.jpg
like the original
BUT in my surprise, it shows:
icon_.jpg
icon_.jpg
icon_.jpg
icon_.jpg
Why?
Where is the $a_0_1 gone? Surely I missed something but I cannot
find it.
Can you tell me how to reproduce the exact filename so?
Best regards,
--
Tôba
Reply to: