Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试匹配一行并使用 sed 命令替换它。就像是
aaa = 10 aaa =10 aaa=10
我的 sed 正则表达式应该匹配所有这些模式,并且应该替换为 bbb=5 之类的内容。我试过了
sed -i '/ *aaa *= */bbb=5'
但这不适用于所有模式。任何帮助都会非常显着。
sed -i 's/\s*aaa\s*=\s*[0-9]*/bbb=5/' input_file
cat a | sed -e '1s/aaa =10/bbb=10/' -e '2s/ aaa =10/bbb=10/' -e '3s/aaa=10/bbb=10/'
cat myfile | sed 's/\s*aaa\s*=\s*\(.*\)/bbb = \1/'
\s 字符类同时匹配制表符和空格