Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Lonely spacecowboy
- X-seq: zsh-users 11347
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: meino.cramer@xxxxxx
- Subject: Re: Lonely spacecowboy
- Date: Tue, 27 Mar 2007 19:44:57 +0100
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20070327175336.GA22601@solfire>
- Mail-followup-to: meino.cramer@xxxxxx, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20070327175336.GA22601@solfire>
On Tue, Mar 27, 2007 at 07:53:36PM +0200, meino.cramer@xxxxxx wrote:
>
> Hi,
>
> I _always_ fail with constructions like
>
> cat file.txt | while read file
> do
> <cmd> "${file}"
> done
>
> when file.txt containing one file per line and
> a filename looks like:
>
> This is an odd filename.txt
>
> . Is there one for all cure for such a constellation?
> Too much space gives me headaches ! ;)
[...]
Should be alright. zsh is even the one shell where you don't
need the quotes around $file.
Maybe your "cmd" is poorly written and can't cope with filenames
containing blanks.
Problems would come for lines that have leading or trailing
blanks or have backslashes.
Try (with GNU xargs)
xargs -d '\n' -n1 cmd < file.txt
Or
for line (${(f)"$(cat file.txt)"}) cmd -- $line
or
while IFS= read -r line; do
cmd -- $line
done
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author