Lorkenpeist
Lorkenpeist

Reputation: 1495

Run a command multiple times with arguments given from standard input

I remember seeing a unix command that would take lines from standard input and execute another command multiple times, with each line of input as the arguments. For the life of me I can't remember what the command was, but the syntax was something like this:

ls | multirun -r% rm %

In this case rm % was the command to run multiple times, and -r% was an option than means replace % with the input line (I don't remember what the real option was either, I'm just using -r as an example). The complete command would remove all files in the current by passing the name of each file in turn to rm (assuming, of course, that there are no directories in the current directory). What is the real name of multirun?

Upvotes: 0

Views: 838

Answers (1)

Ahmed Masud
Ahmed Masud

Reputation: 22412

The command is called 'xargs' :-) and you can run it as following

ls | xargs echo I would love to rm -f the files

Upvotes: 3

Related Questions