Skip to content

Instantly share code, notes, and snippets.

@prelongs
Created March 24, 2014 14:53
Show Gist options
  • Save prelongs/9741679 to your computer and use it in GitHub Desktop.
Save prelongs/9741679 to your computer and use it in GitHub Desktop.
#Sed是一个基本的查找替换程序
#(不指定列数,默认是包含a的第一列)将1.txt文件中包含a的第一列中的a替换为A,并将结果写入n.txt文件中。
cat my.txt|sed s/a/A/ >n.txt
#指定第二列,将1.txt文件中包含a的第二列中的a替换为A,并将结果写入n.txt文件中。
cat my.txt|sed s/a/A/2 >n.txt
#将1.txt文件中的所有a替换为A,并将结果写入n2.txt文件中。该语句也可以在shell脚本中使用
cat './1.txt ' |sed s/a/A/g >n2.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment