【问题标题】:SED - "Filename too long" on a variableSED - 变量上的“文件名太长”
【发布时间】:2021-08-28 08:49:54
【问题描述】:

我正在尝试修改存储在如下变量中的 json:

PS:(这个错误也被 here 覆盖了,但我尝试了相同的过程使终端退出)。

#The variable has some information about a json file (around 10 keys).
infos = [{"id":512,"hostName":"PC-1","pcModel":"Dell","diskType":"Samsung:...}]
#I want to modify the key where "Win10" is written and replace it with "Ubuntu" like this
sed -i "s/Win10/Ubuntu/g" "$infos"
#Then I get the error
bash: /bin/sed: Argument list too long

sed 有没有办法避免这个错误?

谢谢

【问题讨论】:

    标签: ubuntu sed terminal


    【解决方案1】:

    这可能对你有用(GNU sed 和并行):

    parallel sed -i 's/Win10/Ubuntu/g' {} ::: $infos
    

    将就地并行编辑文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-14
      • 2015-03-14
      • 2014-05-30
      • 2015-04-18
      • 2017-11-30
      • 2016-12-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多