On Wed, 29 Jul 2015, Tony Baechler wrote:
What I'm trying to do is extract the BBC PID from the downloaded files. It's
a lower case alphanumeric string which starts with a letter and is eight
characters. In my case, the first letter is always "b" or "p," so if I could
use something like grep to just extract the first lower case letter followed
by a number up to the next underscore, that would be good. I don't think
grep will just print a matching phrase, only the matching line. Here are
some example filenames:
5_live_Science_-_Coding_and_Computers_b062dj5j_default.mp3
Witness_-_The_Sinking_of_the_USS_Indianapolis_p02wdykn_default.mp3
Discovery_-_A_Scientific_View_of_Agriculture_p0053gbd_default.mp3
Click_-_05_10_2010_p00b18gp_default.mp3
You can use basename to get rid of the end.
$ basename Click_-_05_10_2010_p00b18gp_default.mp3 _default.mp3
Click_-_05_10_2010_p00b18gp
You could then use cut with this youtput to get what ou want.
HTH,
Geoff.
_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list