wc --统计行数,单词数,字符数
cut --获取某些字符
sort --排序
uniq --去除重复的行
——————————————————————————————————————————————————
cut: 参考http://www.computerhope.com/unix/ucut.htm
cut可以对file(或stdin或pipe)的每行抽取出希望抽取的部分extract(cut out) selected fields of each line of afile.
[用法]
cut -bLIST [-n] [file] ---b 字节,-n 防止多字节被分割
cut -cLIST [file] ---c 字符
cut -fLIST [-dDELIM] [-s][--output-delimiter=STRING] [file] ---f 分割的字段
LIST---只需要抽取 位置,范围可以是1 ; 1,5 ; 1-5; -5(即1-5), 3- (3到末尾)
delimiter是分隔符号 ,默认是tab键
例子: echo"this is min" | cut -b1-6 返回this I
echo"this is min" | cut -c1-6,返回this I
echo "this is min" | cut -f1,3 返回this min,按照默认的TAB进行分割,返回结果还是按照TAB
echo "this_is_min" | cut -f1,3-d"_" 返回this_min,按照指定的_进行分割,返回结果使用_分割。
注意: 对于没有DELIM的行会完全返回,如果不希望返回可以使用-s;
默认返回的各个域仍按照-d指定的DELIM分割显示,若输出想使用其他分隔符,可以用--output-delimiter=STRING
1. echo"this_is_min" | cut -f1,3 -d"_"--output-delimiter="-" 返回结果为this-min
2. cut -f 1,3 -d ':' --output-delimiter=$'\t' /etc/passwd
要查看linux下当前所有的用户: cat /etc/passwd | cut -f1,3 -d:
例如:
###################################################################
## ckinstance.ksh ##
###################################################################
echo "`date` "
echo "Oracle Database(s) Status `hostname` "
namelst=`ps -ef|grep ora_pmon|grep -vgrep|awk '{print $8}'|cut -c10-15`
for name in $namelst
do
if [ -z $name];then
echo "Oracle Instance - $name: Down"
else
echo "Oracle Instance - $name: Up"
fi
done