Unix Linux 第三方实用Shell工具集

 

第三方就是我方啦.

 

1. path

环境变量$PATH不会换行,看起来很费劲,path将$PATH分行输出

echo -e ${PATH//:/'/n'}

2. classpath

类似path

echo -e ${CLASSPATH//:/'/n'}

3. rmall

递归的将某个目录下所有满足条件的文件和子目录删除

for file in $( find "${1:-not.exist}" -name "${2:-not.exist}" ); do

    rm -rf $file

done

4. pkill

按名称kill进程,linux提供了pkill,当aix之类的没有提供;下面的脚本依赖于ps的输出格式,各个平台不同,需要微调

aix: for pid in $( ps xu | grep "${1:-arg.not.exist}" | cut -f3 -d' ' | tr ' ' "/n" ); do

    kill -9 $pid

done

red-hat: for proc in $( ps | grep "${1:-notexit}" | cut -f1 -d' ' ); do

    kill -9 $proc

done

5. linkto

批量创建符号链接;有时需要拷贝某个目录的众多子目录中的一两个,而为其它所有的子目录创建符号链接

src=${1:-not.exist}

for file in $( ls $src ); do

    ln -s $src/$file $file

done

6. findinfiles

搜索包含特定字符串的文件;可能find本身或grep本身就能做吧,参数太多了,不会用

for file in $(find $1 -name "$2"); do
    if grep -n "$3" $file;then
      echo 'found in ' $file
    fi
done

 

下载 Sky Shell Utility: http://cosoft.org.cn/project/showfiles.php?group_id=5717

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值