zsh-users
 help / color / Atom feed
From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Aryn Starr <whereislelouch@icloud.com>
Cc: zsh-users@zsh.org
Subject: Re: Get the result of the last glob
Date: Wed, 21 Aug 2019 16:17:52 +0100
Message-ID: <20190821151752.ftwx7demdwsnxjtu@chaz.gmail.com> (raw)
In-Reply-To: <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

       reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <918ED85F-9DE5-4365-B962-45AD4AADDF46__5329.09398186661$1566393766$gmane$org@icloud.com>
2019-08-21 15:17 ` Stephane Chazelas [this message]
2019-08-21 15:43   ` Bart Schaefer
2019-08-21 13:21 Aryn Starr
2019-08-21 14:31 ` Daniel Shahaf
2019-08-21 14:34   ` Daniel Shahaf
2019-08-21 14:40   ` Aryn Starr
2019-08-21 14:47     ` Daniel Shahaf
2019-08-21 20:54     ` Mikael Magnusson
2019-08-22  5:36       ` Aryn Starr
     [not found]       ` <6B392E5A-528B-4E73-8DF4-A10D6775D5FB__35805.0242810108$1566452299$gmane$org@icloud.com>
2019-08-22  7:32         ` Stephane Chazelas
2019-08-22  7:35           ` Aryn Starr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190821151752.ftwx7demdwsnxjtu@chaz.gmail.com \
    --to=stephane.chazelas@gmail.com \
    --cc=whereislelouch@icloud.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git