Sed & Awk每日一例之一


Sed & Awk每日一例之一
 
1、sed [options] {sed-commands} {input-file}
 
sed -n 'p' /etc/passwd
 
2、sed [options] -f {sed-commands-in-a-file} {input-file}
 
$ vi test-script.sed 
/^root/ p 
/^nobody/ p 
 
$ sed -n -f test-script.sed /etc/passwd
 
3、sed [options] -e {sed-command-1} -e {sed-command-2} {input-file}
 
sed -n -e '/^root/ p' -e '/^nobody/ p' /etc/passwd
 
sed -n \ 
-e '/^root/ p' \ 
-e '/^nobody/ p' \ 
/etc/passwd
 
4、sed [options] '{ 
           sed-command-1 
           sed-command-2 }' input-file
 
sed -n '{ 
  /^root/ p 
  /^nobody/ p 
}' /etc/passwd

相关内容

    暂无相关文章