* Surely this can be done easier...
@ 2003-12-24 21:10 DervishD
2003-12-24 21:43 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: DervishD @ 2003-12-24 21:10 UTC (permalink / raw)
To: Zsh Users
Hi all :))
I have a file containing a list of files, and I want those files
in a command line. The problem is that the filenames contain weird
characters, spaces and so on. Currently I do the following:
$ while read line ; do array=($array "$line") ; done < listing
$ command $array
I've tried things like 'command $(cat listing)', but obviously
they don't work because quoting.
Can this be done simpler? I think that I made this same question
a time ago, but I haven't found it in the mailing list archive :(
Thanks a lot in advance and happy holidays (if any) ;))
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Surely this can be done easier...
2003-12-24 21:10 Surely this can be done easier DervishD
@ 2003-12-24 21:43 ` Bart Schaefer
2003-12-24 23:59 ` DervishD
0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2003-12-24 21:43 UTC (permalink / raw)
To: Zsh Users
On Dec 24, 10:10pm, DervishD wrote:
}
} I have a file containing a list of files, and I want those files
} in a command line. The problem is that the filenames contain weird
} characters, spaces and so on.
This is pretty close to a FAQ.
First you read the entire file like this:
$(<listing)
Next you need to quote that to protect the lines from being joined:
"$(<listing)"
Next you split on line breaks:
${(f)"$(<listing)"}
And that's the argument of the command:
command ${(f)"$(<listing)"}
In some older versions of zsh you need to move the quotes outside the
whole expression:
command "${(f)$(<listing)}"
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Surely this can be done easier...
2003-12-24 21:43 ` Bart Schaefer
@ 2003-12-24 23:59 ` DervishD
0 siblings, 0 replies; 3+ messages in thread
From: DervishD @ 2003-12-24 23:59 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Zsh Users
Hi Bart :)
* Bart Schaefer <schaefer@brasslantern.com> dixit:
> } I have a file containing a list of files, and I want those files
> } in a command line. The problem is that the filenames contain weird
> } characters, spaces and so on.
> This is pretty close to a FAQ.
Yes O:) You can see the solution in the Examples of section
'Parameter Expansion' in the manual (well, now that I know what to
look for).
> $(<listing)
> "$(<listing)"
> ${(f)"$(<listing)"}
> command ${(f)"$(<listing)"}
Oh, I see where was the problem :(( It was entirely my fault. I
was doing more or less the same (I even tried with ps:\n:), but using
$(cat listing) instead of the command substitution. The problem was
that I was using 'print' as the command and I saw the lines without
quoting, of course! What I meant, what I wanted to check, is pressing
Tab and seeing the list of files from 'listing' quoted and put on the
command line. Instead I pressed Enter and, obviously, I saw the
output of 'print', which is all files together with no quoting or
separation.
The solution, as always, is trying to sleep a bit more :((( Sorry
for the noise and thanks a lot for your answer...
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-12-25 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-24 21:10 Surely this can be done easier DervishD
2003-12-24 21:43 ` Bart Schaefer
2003-12-24 23:59 ` DervishD
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).