[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Forcing For Loop To Accept Spaces
From: |
SoloCDM |
Subject: |
Re: Forcing For Loop To Accept Spaces |
Date: |
Fri, 19 Apr 2002 05:46:18 -0600 |
"Brian J. Fox" stated the following:
>
> Please try:
>
> for i in "foo bar" bar "bar baz"; do rm -i "$i"; done
>
> Date: Thu, 18 Apr 2002 11:25:41 -0700
> From: Ian Macdonald <ian@caliban.org>
> Cc: Paul Jarc <prj@po.cwru.edu>
>
> On Thu 18 Apr 2002 at 12:11:47 -0600, you wrote:
>
> > Paul Jarc stated the following:
>
> >> SoloCDM <deedsmis@aculink.net> wrote:
>
> >>> How do I force a for loop to except files with spaces in their
> >>> names?
>
> >> Quote the spaces. (BTW, you mean "accept", not "except".
> >> "except" is nearly the opposite of what you mean.)
>
> > It didn't work. Even with the quotes around the whole name it
> > didn't work.
>
> What are you using?
>
> This works for me:
>
> [ianmacd@caliban ~]$ for i in 'foo bar'; do echo $i; done foo bar
In the attached script you'll notice I tried redirecting the data to a
file and storing it in a variable. Either way it doesn't work. The
files come out broken up in the for loop. In the "echo $MFILES"
they're not broken.
--
Note: When you reply to this message, please include the mailing
list/newsgroup address and my email address in To:.
*********************************************************************
Signed,
SoloCDM
#!/bin/sh
#
#MFILES=`find $mredm -type f \( -iname *personal* -o -iname .*personal* \)
-print | sed "s+ +' '+g"`
#find $mredm -type f -maxdepth 3 \( -iname *personal* -o -iname .*personal* \)
-print | sed -e "s+^+'+g" -e "s+$+'+g" > sample-data
MFILES=`find $mredm -type f -maxdepth 3 \( -iname *personal* -o -iname
.*personal* \) -print | sed -e "s+^+'+g" -e "s+$+'+g"`
#echo $MFILES
#exit 1
#for f in `cat sample-data`
for f in ${MFILES}
do
#/bin/./ls -hFlA "$f"
echo $f
done
- Forcing For Loop To Accept Spaces, SoloCDM, 2002/04/18
- Re: Forcing For Loop To Accept Spaces, Paul Jarc, 2002/04/18
- Re: Forcing For Loop To Accept Spaces, SoloCDM, 2002/04/18
- Re: Forcing For Loop To Accept Spaces, SoloCDM, 2002/04/18
- Re: Forcing For Loop To Accept Spaces, Ian Macdonald, 2002/04/18
- Re: Forcing For Loop To Accept Spaces, Brian J. Fox, 2002/04/18
- Re: Forcing For Loop To Accept Spaces,
SoloCDM <=
- Re: Forcing For Loop To Accept Spaces, Brian J. Fox, 2002/04/19
- Re: Forcing For Loop To Accept Spaces, Andreas Schwab, 2002/04/19
- Re: Forcing For Loop To Accept Spaces, Brian J. Fox, 2002/04/19
- Re: Forcing For Loop To Accept Spaces, Paul Jarc, 2002/04/18
- Re: Forcing For Loop To Accept Spaces, SoloCDM, 2002/04/19
- Re: Forcing For Loop To Accept Spaces, Brian J. Fox, 2002/04/19