From owner-freebsd-questions Thu Sep 27 1:19:46 2001 Delivered-To: freebsd-questions@freebsd.org Received: from hoemail2.firewall.lucent.com (hoemail2.lucent.com [192.11.226.163]) by hub.freebsd.org (Postfix) with ESMTP id 6EEAD37B432 for ; Thu, 27 Sep 2001 01:19:41 -0700 (PDT) Received: from ukmail.uk.lucent.com (h135-86-160-50.lucent.com [135.86.160.50]) by hoemail2.firewall.lucent.com (Switch-2.1.3/Switch-2.1.0) with ESMTP id f8R8J3w09174; Thu, 27 Sep 2001 04:19:08 -0400 (EDT) Received: from yahoo.com (mlgw010.uk.lucent.com [135.86.193.189]) by ukmail.uk.lucent.com (8.8.8+Sun/EMS-1.5 sol2) id JAA05345; Thu, 27 Sep 2001 09:18:55 +0100 (BST) Message-ID: <3BB2E0EF.26BA27E5@yahoo.com> Date: Thu, 27 Sep 2001 09:18:55 +0100 From: Alexander Thorp Organization: Lucent Technologies X-Mailer: Mozilla 4.6C-CCK-MCD EMS-1.4 [en] (X11; I; SunOS 5.6 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-questions@freebsd.org Cc: dsj@sylvester.dsj.net Subject: Re: regex w/ sed and bash expression Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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