xargs doesn't recognize bash aliases

后端 未结 6 514
猫巷女王i
猫巷女王i 2020-12-13 03:21

I\'m trying to run the following command:

find . -iname \'.#*\' -print0 | xargs -0 -L 1 foobar

where \"foobar\" is an alias or function def

6条回答
  •  -上瘾入骨i
    2020-12-13 03:59

    This doesn't work because xargs expects to be able to exec the program given as its parameter.

    Since foobar in your case is just a bash alias or function there's no program to execute.

    Although it involves starting bash for each file returned by find, you could write a small shell script thus:

    #!/bin/bash
    . $(HOME)/.bashrc
    func $*
    

    and then pass the name of that script as the parameter to xargs

提交回复
热议问题