Sed解释器脚本-就地

Sed解释器脚本-就地,sed,Sed,是否可以“就地”(-i)运行sed解释器脚本 这给了我以下错误: /usr/bin/sed: -e expression #1, char 7: unknown command: `f' 我试图搜索它,但只找到了#/usr/bin/sed-nf(出于某种原因,它可以正常工作) 顺便说一句:我知道我可以运行bash脚本和sed-I命令,但感觉不太对劲:D 编辑: 我只是在更正一些JSON配置文件。使用PythonJSON解析器会删除所有格式和注释(!),所以这对我不起作用。我已经尝试了所有可能的

是否可以“就地”(-i)运行sed解释器脚本

这给了我以下错误:

/usr/bin/sed: -e expression #1, char 7: unknown command: `f'
我试图搜索它,但只找到了
#/usr/bin/sed-nf
(出于某种原因,它可以正常工作)

顺便说一句:我知道我可以运行bash脚本和
sed-I
命令,但感觉不太对劲:D

编辑:

我只是在更正一些JSON配置文件。使用PythonJSON解析器会删除所有格式和注释(!),所以这对我不起作用。我已经尝试了所有可能的组合
sed-I-f
sed-f-I

编辑:

对于那些不信的人:这是整个剧本。希望你喜欢:D

#!/usr/bin/sed -if 

# Tabs - change height
/\/\/ Tab set/,/\}\,/ {
    s/"tab_width": .*,/"tab_width": 50,/;
    s/"tab_height": .*,/"tab_height": 27,/;
}

# VScroll bar
/\/\/ Overlay vertical puck/,/\}\,/ {

# Width
s/"content_margin": .*/"content_margin": [3,38],/
# Color
/content_margin/ {
    a\
    "layer0.tint":[173,216,230],
    a\
    "layer0.opacity": 0.2,
    }
}

# HScroll bar - width
/\/\/ Overlay horizontal puck/,/\}\,/ {
    s/"content_margin": .*/"content_margin": [16,3],/
}

# Status bar - height
/\/\/ Status bar container/,/\}\,/ {
    s/"content_margin": .*/"content_margin": [15, 4]/
}

# Side bar - rows
/\/\/ Sidebar tree || entries/,/\}\,/ {
    s/"row_padding": .*/"row_padding": [8,5],/
    s/"indent_offset": .*/"indent_offset": 10,/
}

# Side bar - folder icon
/\/\/ Sidebar folder opened/,/\}\,/ {
s/"layer0.texture": "Seti_UI\/icons\/folder_open@2x.png",/"layer0.texture":          "Seti_UI\/icons\/folder@2x.png",/
}

根据,这将不起作用,因为在
#上不可能(可移植地)使用多个参数行。答案是可以接受的(至少对我来说)解决办法。

您到底想做什么?发布完整的
sed
命令。请尝试
sed--help
查看是否支持
f
,并确保正确使用它
sed-f脚本文件
sed-i-f脚本文件
和no
#/usr/bin/sed
所以,我将不得不从bash脚本运行
sed
:驻留,它不一定是bash,只是任何可以编写sed NOOP并从中执行sed的语言。我会处理这个问题。谢谢:)
#!/usr/bin/sed -if 

# Tabs - change height
/\/\/ Tab set/,/\}\,/ {
    s/"tab_width": .*,/"tab_width": 50,/;
    s/"tab_height": .*,/"tab_height": 27,/;
}

# VScroll bar
/\/\/ Overlay vertical puck/,/\}\,/ {

# Width
s/"content_margin": .*/"content_margin": [3,38],/
# Color
/content_margin/ {
    a\
    "layer0.tint":[173,216,230],
    a\
    "layer0.opacity": 0.2,
    }
}

# HScroll bar - width
/\/\/ Overlay horizontal puck/,/\}\,/ {
    s/"content_margin": .*/"content_margin": [16,3],/
}

# Status bar - height
/\/\/ Status bar container/,/\}\,/ {
    s/"content_margin": .*/"content_margin": [15, 4]/
}

# Side bar - rows
/\/\/ Sidebar tree || entries/,/\}\,/ {
    s/"row_padding": .*/"row_padding": [8,5],/
    s/"indent_offset": .*/"indent_offset": 10,/
}

# Side bar - folder icon
/\/\/ Sidebar folder opened/,/\}\,/ {
s/"layer0.texture": "Seti_UI\/icons\/folder_open@2x.png",/"layer0.texture":          "Seti_UI\/icons\/folder@2x.png",/
}