环境为bash使用c风格的转义字符,即字符串前使用$ sed -i "" -e $'s/$/\tgun/g' gun.txt 参考文献: Using sed on Mac OS 10 to replace tab character in text files 在Mac OS 10上使用sed替换文本文件中的制表符