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

你可能感兴趣的:(Unix Linux 第三方实用Shell工具集)