![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is the output of echo * | shailja | UNIX for Dummies Questions & Answers | 4 | 06-29-2007 06:27 AM |
| piping output to echo | A1977 | Shell Programming and Scripting | 3 | 11-01-2006 04:58 AM |
| Store output and Echo | meyerder | Shell Programming and Scripting | 2 | 05-14-2006 06:44 AM |
| Weird bootlist output | davew1099 | AIX | 4 | 10-12-2005 06:52 AM |
| Passing output of sed/echo to a variable | donflamenco | Shell Programming and Scripting | 11 | 07-13-2005 07:08 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Code:
#!/bin/bash
INPUT=$1
if [ "$INPUT" -lt "10" ]
then
INPUT=0$1
TRACKNUMBER=$INPUT
fi
TRACKNUMBER=$INPUT
echo "Track Number:" $TRACKNUMBER
if [ ! -e "split-track${TRACKNUMBER}.wav" ]
then
echo "File Does Not Exist!: split-track"${TRACKNUMBER}".wav"
exit 0
fi
CUEFILE="$2"
CDTITLE=`less "$CUEFILE"|grep -B10 FILE|grep TITLE|sed 's/TITLE\ "//'|sed 's/^[ \t]*//'|sed '
s/"//'`
#|sed 's/ /\\ /g'`
CDPERFORMER=`less "$CUEFILE"|grep -B10 FILE|grep PERFORMER|sed 's/PERFORMER\ "//'|sed 's/^[ \
t]*//'|sed 's/"//'`
TRACKTITLE=`less "$CUEFILE" |grep -A4 TRACK\ $TRACKNUMBER|grep TITLE|sed 's/TITLE\ "//'|sed '
s/^[ \t]*//'|sed 's/"//'`
PERFORMER=`less "$CUEFILE" |grep -A4 TRACK\ $TRACKNUMBER|grep PERFORMER|sed 's/PERFORMER\ "//
'|sed 's/^[ \t]*//'|sed 's/"//'`
echo "CD Performer: $CDPERFORMER"
echo "CD Title: $CDTITLE"
echo "Track Title: $TRACKTITLE"
echo "Track Performer: $PERFORMER"
echo $CDPERFORMER $CDTITLE
echo $TRACKNUMBER $TRACKTITLE
Quote:
some more oddity, if I replace the last two echo commands with: Code:
echo "\"$CDPERFORMER\"" echo "\"$CDTITLE\"" echo "\"$TRACKNUMBER\"" echo "\"$TRACKTITLE\"" Quote:
Code:
echo "\"$CDPERFORMER\" " echo "\"$CDTITLE\" " echo "\"$TRACKNUMBER\" " echo "\"$TRACKTITLE\" " Quote:
"Santana - Abraxas - 02 - Black Bagic Woman - Gypsy Queen" anyone know what I'm doing wrong? thanks!! |
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
I really wonder about your use of less inside a script. Does it bring some benefit over simply reading the file? Quote:
Code:
CDPERFORMER=`grep -B10 FILE "$CUEFILE" |
tr -d '\015' |
sed -n 's/^[ ][ ]*PERFORMER[ ][ ]*"\([^"]*\)*"/\1/p'`
|
|
|||
|
Quote:
Quote:
|
|
|||
|
Quote:
Quote:
Quote:
yea, the first grep could probably be avoided, but I don't know how exactly. still doesn't explain why my desired output is not working though. of course, any help with sed would be appreciated. I've tried reading some of the online FAQ's, etc. but they all seem to assume some knowledge which I am not privy to... |
|
|||
|
Did you try trimming the assumed carriage returns from the file? If something is fetching data from the Internet then the protocol is probably using carriage returns, and they might survive into your files (depending on the client which fetches them).
There's a book about awk & sed from O'Reilly, it's very old but also very much worth reading. Also most Unix intro books have a few chapters dedicated to regular expression tools in general, and grep and sed in particular, then moving on to awk. The manual page is not particularly gruesome, either, although of course it's primarily intended as a reference, not a tutorial. |
|
|||
|
Quote:
Quote:
|
|||
| Google UNIX.COM |