Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Simpler Version' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Simpler Version
Authored by: FunkyOdor on Oct 06, '04 12:51:13PM

Instead of piping "sed" results one into another like this, use sed's "-e" option to stack them. For example:

grep 'goo' filename | sed -e 's/blah//g' -e 's/goo/howdy/g'

is equivalent to:

grep 'goo' filename | sed 's/blah//g' | sed 's/goo/howdy/g'

but more efficient and easier to read from a code maintanence point of view.



[ Reply to This | # ]
Simpler Version
Authored by: tamás on Oct 06, '04 03:33:58PM

To follow up on the recommended use of -e and to remove the tabs before the protocol (file, http, rtsp) in the resulting text file, this works:


#!/bin/sh

grep "<key>Location</key>" "$HOME/Music/iTunes/iTunes Music Library.xml" \
| sed -e 's/<key>Location<\/key><string>//g' -e 's/<\/string>//g' \
-e 's/%20/ /g' -e s/^[^fhr]*//g | sort > $HOME/Desktop/iTunes.txt


[ Reply to This | # ]