Re: How to extract string from filename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks! Yes, that worked. I had to use rev twice as you suggested. This single line script seems to do what I want:

for file in *.mp3; do basename $file _default.mp3 | rev | cut -d_ -f1 | rev; done

I can then design a further wrapper script to take the PID, download the web page and name it the same as the original filename with an html extension. This is perfect! I hadn't heard of rev before. I not only learned something new, but I now have a solution for the next time I run into a situation like this.

On 7/29/2015 4:58 AM, Willem van der Walt wrote:
Hi,
I usually use rev twice, e.g.
echo blablabla_bla_p123_default.mp3|rev|cut -f2 -d'_'|rev
HTH, Willem


_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list



[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]