-----BEGIN PGP SIGNED MESSAGE-----
Mark -
You're right, that's an odd inconsistency. I thought perhaps we could
modify IFS, but it uses space/tab/newline by default, yet it doesn't
seem to be splitting on the space in the first example. (I would
think it should.) These two commands produce identical files
(according to `cat -vet`, which should show me nonprinting
characters):
LIST=*; for i in $LIST; do echo $i >> listout1;done
ls >> listout2
Obviously, there's something in one output that's not in the other,
but I don't know what it is. So ... I don't have an answer for you,
but you might consider using a dash of Perl instead. This snippet
produces what you want, and works with both the output files from the
previous two commands:
open(LIST,"listout2");
while (<LIST>) {
print;
}
Perl splits input on newlines unless told not to.
If you do find a solution to the bash dilemma, please post it!
- -d
- --
David Talkington
Community Networking Initiative
[EMAIL PROTECTED]
217-244-1962
PGP key: http://www.prairienet.org/~dtalk/dt000823.asc
Mark Ivey wrote:
>Ok, I have some directories with spaces in the names:
> $ ls -1
> Astral Projection/
> Divinorum/
> Fusion 19/
> GoaArchive/
> Starfire Records/
>
>And I'm trying to write a bash script to modify files in each directory.
>The spaces are giving me problems. Here are two short bash scripts:
> LIST=*; echo $LIST;
> LIST=$(\ls); echo $LIST;
>
>Now, they both _seem_ to give the same output. It looks like this:
> Astral Projection Divinorum Fusion 19 GoaArchive Starfire Records
>
>Here are two more scripts, similar to the first 2:
> LIST=*; for NAME in $LIST; do echo "-->" $NAME; done
> LIST=$(\ls); for NAME in $LIST; do echo "-->" $NAME; done
>
>They give different output. The first one gives:
> --> Astral Projection
> --> Divinorum
> --> Fusion 19
> --> GoaArchive
> --> Starfire Records
>
>and the second one gives:
> --> Astral
> --> Projection
> --> Divinorum
> --> Fusion
> --> 19
> --> GoaArchive
> --> Starfire
> --> Records
>
>
>So, how do I get the second one to work like the first one? I've tried
>putting quotes around the filenames (\ls -Q), but it doesn't work. It
>still splits the names at the spaces. I will have other files alongside
>the directories later, so I can't just use the * version. Also, I know I
>could use the -exec flag on the find command, but I am having this problem
>with a few other for loops that I can't use find on, so I would really
>like to know how to get the for command to work. Thanks....
>
>
>-Mark Ivey-
>
>
>
>_______________________________________________
>Redhat-list mailing list
>[EMAIL PROTECTED]
>https://listman.redhat.com/mailman/listinfo/redhat-list
>
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8
Comment: Made with pgp4pine 1.75-6
iQEVAwUBOiNMbL1ZYOtSwT+tAQE+vwf/R0OuktNs04anePjJQf10t2r/VqRV1ey6
b1JbUvMXGGmvuk20fiEHSUn9mAgP5ThDmcj5BwIv+FrhPTWdEQhEbMZFD72xeR+T
jtzvIp2ZEDefPED8g6aDX4V2/LZY0wKC7QxPOGzASGAy05l3sY6Dnfl7VG2sP9un
1mTSt6zjKc9b8Fbpk/cHpSTq6dW2xU+GI5t6dTWS9bfQ7O7AViwSM1bnAJUSCn3Y
gqbpJskduDgXCznXT6VxjcPCMmFIpdI5qkBlOjGLsaVvP17XGvg3OtVAJiZrJsFn
51w6Sb9APQji61VHfMJD1vjFN6MKzbwE2khNdZky1/QkviOwfJP0Gw==
=FDqO
-----END PGP SIGNATURE-----
_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list