加载中…
  
博文
标签:

it

分类: shell

第一种方法:

#!/bin/bash

echo -e '\nThis is a program to find the file in special directory which include keyword!\n\n'

if [ '$1' == '' ]; then
echo -e 'Please input the keyword behind the $0\.\n\n'
exit 0
fi

keyword=$1

dir=.
if [ '$2' != '' ]; then
dir=$2
fi

test ! -d $dir && echo -e 'The $dir is not exist in your system\.\n\n' && exit 0

count=0
filelist=`ls -R $dir 2> /dev/null | grep -v '^$'`
for filename in $filelist
do
temp=`echo $filename | sed 's/:.*$//g'`
if [ '$filename' != '$temp' ]; then
curdir=$temp
#echo 'current dir = $curdir'
else
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有