Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Get the result of the last glob
- X-seq: zsh-users 24171
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Aryn Starr <whereislelouch@xxxxxxxxxx>
- Subject: Re: Get the result of the last glob
- Date: Wed, 21 Aug 2019 16:17:52 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9Ig1K0Tuf09gObXg3xIMyWVcaonbGGofJgi/aR9XLJc=; b=ax/6NrbUNzmquL9itq1E4l0CbpKPVKZ0SKhSVd9lr5s79mhJRDWSH630nPXiYfoK6v GI3aKTe+jvYlhulPAzcjxfhosH5VlP8hWgh8pFDT25MHSav3BB1VI954QJRa0Oja9LPi 7Ys+YgeRwCVi2EwS0oXuPJ35IHA+2vy2TIsIeG0+itdCLqpV2vKRB89W3YmcTkjNd+py Z4YslWONBNZrMOLaAy+Fs17p1KcCOC2lomhmJBOtHB3nZ2G/4KkF6aexKLCZ1u3MPGQx VqRrE30twp/m1SIvECk2/cW2fdNZXijw1FefYN2Qfn4qbvvyHjJfD/58CAeXxPTyDlXx rmYQ==
- In-reply-to: <918ED85F-9DE5-4365-B962-45AD4AADDF46__5329.09398186661$1566393766$gmane$org@icloud.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mail-followup-to: Aryn Starr <whereislelouch@xxxxxxxxxx>, zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <918ED85F-9DE5-4365-B962-45AD4AADDF46__5329.09398186661$1566393766$gmane$org@icloud.com>
2019-08-21 17:51:11 +0430, Aryn Starr:
> Is there a way to get the result of the last glob?
> I want to do sth like this in a folder with only one file, somebook.mobi:
>
> ebook-convert * *.epub
>
> Which I want expanded to:
>
> ebook-convert somebook.mobi somebook.mobi.epub
[...]
You could use zargs for that:
autoload -Uz zargs # in ~/.zshrc
zargs -I@ ./* -- ebook-convert @ @.epub
Though I generally find that using a loop is generally quicker,
shorter and safer (and you have more control over what's going
on):
(for f (./*) ebook-convert $f $f.epub)
(using a subshell to get a more deterministic behaviour upon
^C/^Z).
Here, assuming that "ebook-convert" supports the --
end-of-option delimiter (if it doesn't replace -p with -P and *
with ./*), you could also do:
autoload -Uz zmv # in ~/.zshrc
zmv -p ebook-convert '*' '$f.epub'
Or
alias wzmv='noglob zmv -W' # in ~/.zshrc
wzmv -p ebook-convert * *.epub
zmv does some sanity checks which you could find useful here,
like that none of the destination files exist before starting
the moves.
--
Stephant
Messages sorted by:
Reverse Date,
Date,
Thread,
Author