Removing beginning of line with a shell script
Hello,
I am trying to write a script to do the following: given a m3u playlist file, strip off the path of each song listed and leave only the filename itself. So what I want to do, is delete the beginning of each line up through the last occurrence of "/". Thing is, I already had a script that did just this (but alas, I lost it). I remember when I wrote the script, I was really impressed with how easy it was to do - even bragged to my friends about how awesome Linux was for allowing me to write such a simple script. But now I can't find anything like what I found last time. Any ideas? Thanks, Oscar. |
basename?
jlinkels |
basename it is!
One Liner: Code:
cat playlist.m3u | grep -v EXTINF | sed "s|'|'\\\''|;s|^|basename '|;s|$|'|" | bash Code:
#!/bin/bash |
Code:
awk -F/ '!/^#/ {print $NF}' m3u Cheers, Tink |
Quote:
|
Thanks guys. I'll give those a shot as soon as I get back to my computer. This forum is the BEST!
Oscar. |
Quote:
Glad you liked my approach. Cheers, Tink |
Quote:
Code:
$ cat list If you have weird filenames: Code:
$ cat list |
This is interesting:
Code:
root@digital:~# cat playlist.m3u | wc -l Pretty amazing! |
Which kind of makes the use of awk for certain tasks look
pretty darn good ;} Cheers, Tink |
All times are GMT -5. The time now is 08:20 AM. |