Sponsored Content
Full Discussion: Music Playlist parse/grep
Top Forums Shell Programming and Scripting Music Playlist parse/grep Post 302652953 by DSommers on Friday 8th of June 2012 07:22:08 AM
Old 06-08-2012
Music Playlist parse/grep

Hi.
Please help with a single line bash that will match field 3, and field 2 , if not then echo "Not Found".

Original Music List name; Musiclists.m3u

Format:
Code:
\Music\The Rolling Stones - Angel.mp3
\Music\Maroon 5\Moves Like Jagger.mp3

Make a groomed playlist variable...
Code:
$ playlist="$(cat Musiclists.m3u | sed -e 's/\(.*\)\\/\1;/' -e 's/\(.*\)\ -\ /\1;/' -e 's/\\/\//g' -e 's/\\/\//g' -e 's/.mp3//')

$ echo "$playlist"
/Music/;The Rolling Stones;Angel
/Music/;Maroon 5; Moves Like Jagger

I've got the following to work if I use the actual names, but I want to substitute for every line fed with a variable for field 3 and 2.

Code:
- $ grep -i -w -E 'Stones.*angel' Musiclists.m3u
- $ if ! grep Stones Musiclists.m3u ; then echo "Not Found"; fi
- $ grep -i -w Angel Musiclists.m3u | grep -i -w Stones

How can I correctly...
Code:
$ echo "$playlist" | while read z; do grep -i -w <field3> Musiclists.m3u | grep -i -w <field2> || echo "Not Matched" ; done

I'm not sure which is the best way to go about this.


Thank you.

Last edited by Scrutinizer; 06-08-2012 at 08:45 AM.. Reason: code tags
 

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

parse text or complex grep ?

I have the following file (records from db) and I need to retrieve in another file only two variables and their values. I have a command but works only for one value. grep ^mob: R25-subs.ldi | sed 's/mob: //' | sort | uniq >text_output Can someone please help me? dn:... (4 Replies)
Discussion started by: jacost
4 Replies

2. Shell Programming and Scripting

to parse (or grep) a number from a datafile and write it to tab limited file

Hi All, I have a folder that contain 100's of subfolders namely: Main folder -> GHFG - Subfoders ->10 100 234 102 345 .. .. ... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

3. Shell Programming and Scripting

a playlist for ffmpeg streamer

Hi, I hope I am posting in the right place. I use to stream to justin tv using ffmpeg with that command ffmpeg -re -i "path/to/input.avi" -vcodec libx264 -preset fast -crf 30 -acodec libfaac -ab 128k -ar 44100 -f flv rtmp://live.justin.tv/app/xxxxxxxxxxx I would like to know if a bash... (2 Replies)
Discussion started by: undercash
2 Replies

4. Shell Programming and Scripting

Grep/Parse a .xml file

I have a .xml file similar to the following: <Column> <Name>FIELD1</Name> <Title>CO.</Title> </Column> <Column> <Name>FIELD2</Name> <EditField>TextBox</EditField> <ColumnSpan0>4</ColumnSpan0> <Title>NORMAL</Title> ... (12 Replies)
Discussion started by: jl487
12 Replies

5. Shell Programming and Scripting

Help with Playlist creation script

Hello. I am hoping to have an automated way to create Playlist files from Genre txt files I'll be making with my music collection. This is for use with my WD Live player, and is so that certain albums / artists can live in multiple genre directories when I browse to them from my WD Live player. ... (4 Replies)
Discussion started by: Davinator
4 Replies

6. What is on Your Mind?

Video Playlist for New Users with Under 5 Posts

Hi. I'm working on showing the video player to new users with under 5 posts which shows only videos like the ones below, which are related to the forums, how to use the forums, code tags, usercp, etc.: https://www.unix.com/members/1-albums215-picture1265.png or maybe something minimal and... (5 Replies)
Discussion started by: Neo
5 Replies
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a file name containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 07:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy