[Gllug] More grep stuff

Stuart Sears stuart at sjsears.com
Fri Sep 10 21:29:40 UTC 2004


On Friday 10 September 2004 21:23, Dylan wrote:
> Hi All,
>
> In my quest to extract tag info from ogg files, I have encountered
> another problem...
>
> oggenc allows multiple comment arguments, so I figured I would:
>
> for comment in `ogginfo <file> | grep =
> do
the for command assigns each individual word to $comment in turn
>   comments="-c \"comment\" "$comments
>   done
>
> but this produces, for example:
>
> -c "TRACKNUMBER=7" -c "Love" -c "In" -c "Not" -c "TITLE=Im" -c
> "KDE-ENCODER=kio_audiocd" -c "GENRE=" -c "DESCRIPTION=" -c
> "ARTIST=10cc" -c "ALBUM=Milestones"

> instead of:
>
> -c "TRACKNUMBER=7" "TITLE=Im Not In Love" -c "KDE-ENCODER=kio_audiocd"
> -c "GENRE=" -c "DESCRIPTION=" -c "ARTIST=10cc" -c "ALBUM=Milestones"
so you want to put all of the tags into one long comment tag?
> Obviously, any of the comments can have spaces in the rhs, but I can't
> figure out how to get the lines with spaces to come out complete. I'm
> especially confused since:
how about this (as a small script. Also attached)
#!/bin/bash
# take a filename as the first argument:
file=$1
comments=""
# the next line will wrap. It shouldn't be kept that way!
for line in `ogginfo $file | grep = |cut -f2| sed -e 's,^,-c \"&,' -e 's,$,
\",'`; do
#the 'cut' command strips the leading tab
#(assuming it is a tab, It is in my oggs)
#the 'sed' bit puts the -c and quotes at the
# beginning and end of the line.
comments="$comments $line"
done
# output result on stdout to check it.
echo "comment tags are: "$comments


-- 
Stuart Sears RHCE, RHCX
--
Do not do unto others as you would they should do unto you.  Their tastes
may not be the same.
  -- George Bernard Shaw
-------------- next part --------------
A non-text attachment was scrubbed...
Name: comments.sh
Type: application/x-shellscript
Size: 393 bytes
Desc: not available
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20040910/50913cd4/attachment.bin>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list