Mac下使用sed命令
文件内容
test.txt file content:
aaabbbcccddlinux平台
linux:
sed -i “s/aaa/111/g” test.txt
运行okMac运行
mac:
sed -i “s/aaa/111/g” test.txt
error: sed: 1: “test.txt”: undefined label ‘est.txt’
man sed
-i extension
Edit files in-place, saving backups with the specified extension.
If a zero-length extension is given, no backup will be saved. It
is not recommended to give a zero-length extension when in-place
editing files, as you risk corruption or partial content in situ-
ations where disk space is exhausted, etc.
修改后:sed -i “.bak” “s/aaa/111/g” test.txt 运行,会备份一个.bak的文件。