#!/bin/bash
# find a text in all files of the directory, include the subdirs
# Usage: finddir text
PWD=$(pwd)
DIR=$(du -a $PWD| cut -f2)
for i in $DIR
do
grep -n $* $i
done
######################################################################
#!/bin/bash
# Link all file and directory in the source directory to target directory
# Usage: linkdir sourcedir targetdir
source=$1
target=$2
FILE=$(ls $1)
for i in $FILE
do
ln -s $source/$i $target/$i
done
########################################################################
#!/bin/bash
# remove all directory in the current dir
# Usage: removedir
name=$(ls)
echo "wait..."
for i in $name
do
if [ -d $i ]
then
echo "removing $i"
rm -fr $i
fi
done
echo "done !"
###########################################################################
#!/bin/bash
# rename all files in the current dir with a same prefix, keep the surffix of files
# renamefile prefix
count=0
files=$(ls)
name=""
prefix=$*
suffix=""
for i in $files
do
# the file renamefile must be excluded !
if [ $i != "renamefile" -a -f $i ]
then
# cut the suffix of file
suffix=$(echo $i|cut -d. -f2 )
count=$(expr $count + 1)
name=$prefix$count"."$suffix
mv $i $name
fi
done
###########################################################################
dboo78 于 2005-12-13 16:00:27发表:
不懂,但支持下
jyo200 于 2005-11-30 20:10:43发表:
支持下