Date: Thu, 27 Sep 2001 09:18:55 +0100 From: Alexander Thorp <atecsc@yahoo.com> To: freebsd-questions@freebsd.org Cc: dsj@sylvester.dsj.net Subject: Re: regex w/ sed and bash expression Message-ID: <3BB2E0EF.26BA27E5@yahoo.com>
next in thread | raw e-mail | index | archive | help
files=$(cat listofwavs.txt | sed s/\\\([]\\\[\'\ \"\(\)]\\\)/\\\\\\1/g)
Note: the command isn't enclosed in single quotes - it relies on ksh/bash
swallowing some of the back-slashes before sed sees it.
Alex Thorp
> I'm trying to make a variable expand to include a list of
> filenames with braces and parens as part of the filename. (The
> files are mp3s with brackets and parens, etc, in the filenames
> themselves.) I just want the resulting expansion to insert an
> escape character infront of spaces and special characters so the
> shell can find them.
>
> Example: don mclean - american pie (uncut version).mp3
> and [John Wayne]-[Pledge_of_Allegiance].mp3
>
> What I've got so far is:
>
> *** snip ***
> files=`cat listofwavs.txt | sed -e 's/\([( )\]]\)/\\1/gp'`
>
> burncd -f /dev/acd1c -s ${cdrspeed} -e audio \
> "${audiopath}/${files}" fixate
> *** snip ***
>
> But if I go echo "[" | sed -e 's/\([( )\]]\)/\\1/gp' it just
> returns "[" without the escape. :-(
>
> The group I want to catch is " ", "(", ")", "[", "]".
>
> I want the expansion to create "\ ", "\(", "\)", "\[", "\]".
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3BB2E0EF.26BA27E5>
