bash参数在Linux上列出的时间过长,但在Mac上却没有

时间:2019-05-07 16:05:56

标签: linux bash

这是我运行的shell脚本:

for file in “$d/resources/“*; do
        resourceName=$(basename $file)
        echo “Inserting resouce: $resourceName...”
        resource=`cat $file`
        # Generate id with md5
        resourceId=$((resourceId+1))
        # Insert into resources table
        cqlsh -e “INSERT INTO $TENANT_NAME.resources (id, target,lastUpdateDate,lastUpdateUser,algorithmName,resourceName,resourceContent) VALUES ( $resourceId, ‘template’, toTimestamp(now()), null, ‘$algorithmName’, ‘$resourceName’, \$\$$resource\$\$);” $STORAGE_HOST_ADDRESS $STORAGE_HOST_PORT
    done

在Mac上,它工作正常,但在Linux上,由于$ resource的原因,它抛出错误bash参数列表的时间过长。有人可以告诉如何解决此问题吗?谢谢。

1 个答案:

答案 0 :(得分:1)

Linux每个参数限制为128k。 macOS的参数+环境限制为256k。

改为将查询写入文件,并让cqlsh而不是环境执行该查询:

cqlsh -f myqueryfile host port