Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using shell function like zip0 () { zip -0rq "$1" "$1"; }

And I wanted to use it with xargs like this.

$ seq 1 3 | xargs zip0
xargs: zip0: No such file or directory

But as the error message shows, it doesn't recognized as a command. How can I use xargs with shell function?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You'll have to have xargs invoke the shell:

seq 1 3 | xargs sh -c "zip0 () { zip -0rq "$1" "$1"; }; zip0"
share|improve this answer
    
If it is so complex to use shell function with xargs, I'd write shell script for it. Thanks anyway! –  Tetsu Sep 15 '13 at 1:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.