/usr/bin/jq: Argument list too long error bash

后端 未结 2 1444
旧巷少年郎
旧巷少年郎 2021-01-07 05:38

I want to replace the value in sample json from larger swagger.json file content and it is too large.

Error:
/usr/bin/jq: Argument list too long error bash 
         


        
2条回答
  •  無奈伤痛
    2021-01-07 05:58

    The Q does not explicitly say how $swagger has been set, but it would seem that rather than using --arg swagger $swagger you would be better off using one of the file-oriented command-line options, perhaps along the lines of:

    --argfile swagger swagger.json
    

    There are many alternatives, but to explore these sensibly here, it would be best if you provided at least one complete but very TINY example. (The example does NOT have to illustrate the "Argument list too long" error!)

    Caveat

    If you are worried that the --argfile option is deprecated, then by all means use --slurpfile instead if your jq has it, but note that the latter option wraps the file contents into a JSON array, so you would have to take that into account.

    These and other options are all presented succinctly in the official documentation at https://stedolan.github.io/jq/manual/

提交回复
热议问题