小编bte*_*mnz的帖子

带 xargs 的多线程警告 xargs: warning: 选项 --max-args 和 --replace/-I/-i 是互斥的,忽略先前的 --max-args 值

我在 bash 脚本中有一个 xargs 命令。脚本运行,但返回此警告

xargs: warning: options --max-args and --replace/-I/-i are mutually exclusive, ignoring previous --max-args value
Run Code Online (Sandbox Code Playgroud)

脚本:

function post_thing {
        token=$2
        ##check file exists
        if [ -f $1.thing.json ];
                then
                        response=`curl  -s -o /dev/null -w "%{http_code}"  'https://url.com' --header 'Authorization: Bearer '"$2"'' --header 'Content-Type: application/json' --data @$1.thing.json`
                        mv $1.thing.json $1.thing.json.$response

                else
                echo "File not found: $1.thing.json"
        fi

}
export -f post_thing
seq 100 200 | xargs -n2 -P100  -I {} bash -c 'token='"$token"'; post_thing "$@" "$token"' _ {}
Run Code Online (Sandbox Code Playgroud)

我不明白这是否会影响脚本,或者我需要做什么。看起来脚本正在按预期工作。使用 …

bash xargs

6
推荐指数
1
解决办法
1477
查看次数

标签 统计

bash ×1

xargs ×1