wc, sort ,uniq 命令

30 篇文章 0 订阅
12 篇文章 0 订阅

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

     

 

 


 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值