zsh-users
 help / Atom feed
* SImple way to execute command on list of files?
@ 2019-04-14  8:46 Dominik Vogt
  2019-04-17  2:09 ` Anthony Heading
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Vogt @ 2019-04-14  8:46 UTC (permalink / raw)
  To: Zsh Users

Other than writing an alias or a function, is there a simple way
to call commands that take only one file argument multiple times?

In other words

  $ xpdf *.pdf
  $ ps2pdf a.ps b.ps c.ps

should be executed (semantically) as

  $ for F in *.pdf; do xpdf "$F"; done
  $ ps2pdf a.ps; ps2pdf b.ps; ps2pdf c.ps

I'm looking for a kind of extension for the command syntax.  Of
course I could write a function with that syntax for each command,
but is there a more general way where you can define a list of
commands to treat differently, say

  annoying_commands xpdf ps2pdf gv

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: SImple way to execute command on list of files?
  2019-04-14  8:46 SImple way to execute command on list of files? Dominik Vogt
@ 2019-04-17  2:09 ` Anthony Heading
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Heading @ 2019-04-17  2:09 UTC (permalink / raw)
  To: Dominik Vogt, Zsh Users

On Tue, Apr 16, 2019, at 10:03 PM, Dominik Vogt wrote:
> but is there a more general way where you can define a list of
> commands to treat differently, say
> 
>   annoying_commands xpdf ps2pdf gv
> 

something like this maybe?

wrap_annoying_command() { local i; for i in $~2; $1 $i }
annoying_commands() { local i; for i in $@; alias $i="noglob wrap_annoying_command $i" }
annoying_commands xpdf ps2pdf gv


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-14  8:46 SImple way to execute command on list of files? Dominik Vogt
2019-04-17  2:09 ` Anthony Heading

zsh-users

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

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