Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Prepend/append to the members of a list
- X-seq: zsh-workers 22932
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: Prepend/append to the members of a list
- Date: Mon, 30 Oct 2006 18:54:07 -0800
- In-reply-to: <20061030170919.GA9507@xxxxxxxxxxxx>Comments: In reply to Jörg Sommer <joerg@xxxxxxxxxxxx> "Prepend/append to the members of a list" (Oct 30, 6:09pm)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20061030170919.GA9507@xxxxxxxxxxxx>
On Oct 30, 6:09pm, Jörg Sommer wrote:
}
} % ls !ls*:(s/^/dir/)
}
} But it does not work, because the s/// expression doesn't know ^.
Even if history substitution did understand beginning-of-word, that
still wouldn't work. You'd at the least need :gs and some character
other than slash as the separator.
Usually in this situation I would do something like
% (cd dir; !ls )
Nikolai's suggestion can be tweaked to not require rcexpandparam:
% a=( !ls:* ); ls dir/$^a
Or this:
% ls dir/${^$(echo !{ls:*:q})}
} Or another example:
}
} % cp dir/*.[1-9](:t:s+^+/usr/share/man/man?/+:s/$/.gz/) .
There you're in a bit of a pickle because you're using history modifiers
on a glob pattern, which is even more limited. I believe the closest
you'd get without pain [#] is:
% cp /usr/share/man/man?/${^$(echo dir/*.[1-9](:t)}.gz .
which isn't that much uglier than what you constructed.
Of course, if you do this specific thing often you can do
% function mangz { reply=(/usr/share/man/man?/$REPLY:t.gz) }
% cp dir/*.[1-9](+mangz) .
[#] Pain is safely quoting special characters in the file name:
% cp /usr/share/man/man?/${^$(echo dir/*.[1-9](:te.'reply=${(q)REPLY}'.))}.gz .
--
Messages sorted by:
Reverse Date,
Date,
Thread,
Author