Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell commands on OS X

Status
Not open for further replies.

santanudas

Technical User
Mar 18, 2002
121
GB
Hi guys,

I was trying to write a small bash script, which reads the iTunes’ Library.xml file and then print the name of the songs based on the “given” artist. In the end, I came up with something like this:

Code:
cat ~/Music/iTunes/iTunes\ Music\ Library.xml | tr \\n ' ' | sed 's%</dict>%\n%g' | sed -e 's%<[/[:alnum:]]*>% %g' -e 's/[[:space:]][[:space:]]*/ /g' | grep 'Artist ABBA' | sed -e 's/.*\(file:[[:graph:]]*\).*/\1/g' -e  's%.*/%%g' | sed -e 's/%20/ /g' -e '\,$, s/\.[a-zA-Z0-9]*//' | sort

What is doing is: Reading the file > joining all the lines together > breaking the (putting a new line) after every </dict> (so that all the value between <dict> and <\dict> in a single line now) > grep the Artist name and the associated <Name> value (i.e. song) for every single occurrence.

It's working pretty well under Linux but not on the OS X version of BSD. Any idea why? Many thanks in advance for helping. Cheers!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top