姓名:杨宝秋,OCM,ACE。近8年的TB级数据库设计、建设、管理、运行维护、调优经验,也做了7年的Hp和IBM Rs6000的系统管理员,而且是获得了BCFP认证的SAN管理员,现为中国联通黑龙江分公司数据库主管。
Unix中如何删除除或替代文件中的某个串
上一篇 /
下一篇 2008-01-31 08:29:27
/ 个人分类:Unix
关于tr和sed
# USE tr TO REMOVE CR CHARACTER
tr -d 'r' < oldfile > newfile
# USE sed, IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format
sed 's/.$//' # assumes that all lines end with CR/LF
sed 's/^M$//' # in bash/tcsh, press Ctrl-V then Ctrl-M
# USE sed, IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format
sed "s/$/`echo -e r`/" # command line under ksh
sed 's/$'"/`echo r`/" # command line under bash
sed "s/$var1/$var2/" file1 >file1.out
sed 's/'$var1'/'$var2'/' file1 >file1.out
Multiple substitutions in a single command:
sed -e 's/abc/xyz/' -e 's/lmn/rst/' file1 >file1.out
sed -e 's/abc/xyz/'
-e 's/lmn/rst/'
file1 >file1.out
导入论坛
引用链接
收藏
分享给好友
推荐到圈子
管理
举报
TAG: