xargs doesn't recognize bash aliases

后端 未结 6 516
猫巷女王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条回答
  •  粉色の甜心
    2020-12-13 04:18

    Using Bash you may also specify the number of args being passed to your alias (or function) like so:

    alias myFuncOrAlias='echo'  # alias defined in your ~/.bashrc, ~/.profile, ...
    echo arg1 arg2 | xargs -n 1 bash -cil 'myFuncOrAlias "$1"' arg0
    echo arg1 arg2 | xargs  bash -cil 'myFuncOrAlias "$@"' arg0
    

提交回复
热议问题