How to extract string from filename solved
Tony Baechler
tony at baechler.net
Thu Jul 30 11:52:21 UTC 2015
Hi all,
Thanks very much to all of you. I modified the script posted by Willam and it now does what I want. Yes, scripting is educational. I found out about rev which I didn't know about before. Here is the final script. It seems to do what I want and I'm very greatful. Thanks to all of you for your excellent suggestions! I saved most of them.
#!/bin/bash
#Since there are no spaces in the names, use for loop
for i in $(ls *mp3);do
grab=`echo $i|rev|cut -f2 -d'_'|rev`
wget -q http://www.bbc.co.uk/programmes/$grab -O"`basename $i .mp3`.html"
done
More information about the Blinux-list
mailing list