转 -- 【Shell】【经验】awk sed grep find sort常用配搭用法
2012-04-06 09:33
531 查看
平时也经常会用到awk, grep一类的,今天看到有个小总结,就记录一下。
原址如下:
http://space.itpub.net/519536/viewspace-557309
作为一位DBA,不熟练的掌握Shell是万万不可的,简单列一些常用的Shell命令的用法。
awk '/[Gg]reen/' file
awk '$1 ~/^…a/' file
awk '$0 ~/(Green|green)/' file #等价于egrep "Green|green" file
awk '{print $1}' file | tee file2
awk '{if ($4 ~/Brown/) print $0}' file
awk '{if ($4 !~/Brown/) print $0}' file
awk '{if($1=="条件1" && $4=="条件2") print $0}' file
awk '{if($1=="条件1" || $4=="条件2") print $0}' file
awk '{print length}' file
awk 'BEGIN {print "this is a title"} {print $1} END{print "the end"}' read.txt
awk 'END {print NR}' file #等价于wc –l file
awk 'END {print NF}' file
awk 'END {print FILENAME}' file
sed –n '/e\{2\}/'p file1
sed –n '/e\{2,\}/'p file1
sed –n '/e\{2,3\}/'p file1
sed 's/Tony/Terry/'g file1
grep –w "精确匹配条件" file
grep –i "匹配字符串" file
grep –v "匹配字符串" file
grep –E "条件1|条件2" file
grep [^字符串] file
find . –name "*.sh" | xargs grep expr
find ~ –mtime 2
find / –size 0c
find ~/app –type d #列出根目录下的app目录中所包含的所有文件夹
sort +4n file1
sort –u file
-- The End --
原址如下:
http://space.itpub.net/519536/viewspace-557309
作为一位DBA,不熟练的掌握Shell是万万不可的,简单列一些常用的Shell命令的用法。
awk '/[Gg]reen/' file
awk '$1 ~/^…a/' file
awk '$0 ~/(Green|green)/' file #等价于egrep "Green|green" file
awk '{print $1}' file | tee file2
awk '{if ($4 ~/Brown/) print $0}' file
awk '{if ($4 !~/Brown/) print $0}' file
awk '{if($1=="条件1" && $4=="条件2") print $0}' file
awk '{if($1=="条件1" || $4=="条件2") print $0}' file
awk '{print length}' file
awk 'BEGIN {print "this is a title"} {print $1} END{print "the end"}' read.txt
awk 'END {print NR}' file #等价于wc –l file
awk 'END {print NF}' file
awk 'END {print FILENAME}' file
sed –n '/e\{2\}/'p file1
sed –n '/e\{2,\}/'p file1
sed –n '/e\{2,3\}/'p file1
sed 's/Tony/Terry/'g file1
grep –w "精确匹配条件" file
grep –i "匹配字符串" file
grep –v "匹配字符串" file
grep –E "条件1|条件2" file
grep [^字符串] file
find . –name "*.sh" | xargs grep expr
find ~ –mtime 2
find / –size 0c
find ~/app –type d #列出根目录下的app目录中所包含的所有文件夹
sort +4n file1
sort –u file
-- The End --
相关文章推荐
- 几个常用的文本处理shell 命令:find、grep、xargs、sort、uniq、tr、cut、paste、wc、sed、awk
- 几个常用的文本处理shell 命令:find、grep、sort、uniq、sed、awk
- 常用文本过滤命令笔记(find grep wc awk sed sort uniq split)
- (三) paste 之grep cut paste sort awk sed find uniq 全面总结
- find grep wc awk sed sort uniq split指令详解
- Shell 中grep awk 和 sed常用命令和语法
- 【shell脚本】常用工具的学习grep、sed、awk、cut
- linux文本处理 sort,grep,sed,awk,uniq 用法
- shell常用工具使用——awk、grep以及sed
- shell工具——cut、tr、grep、sort、uniq、re、sed、awk
- grep sed awk find用法
- grep sed awk find的用法归纳
- Shell中的grep、awk和sed的常用命令和语法
- shell学习笔记[grep,sed,awk,sort,for,until,while]
- Linux的shell脚本grep、sed、awk练习和diff、patch、cut、sort介绍
- Shell中的grep、awk和sed的常用命令和语法
- linux文本处理 sort,grep,sed,awk,uniq 用法
- GREP、SED、AWK、TR、SORT、UNIQ的一些用法
- Shell中的grep、awk和sed的常用命令和语法
- (四)find 之grep cut paste sort awk sed find uniq 全面总结