#!/bin/awk
{
if(/[ ]*create table/){
name=$0
sub("[ ]*create table ","",name)
}
print>name
}
就是判断当前行裤氏没是不是create table 如果是,就设置name变量为table 名。胡纳随后把当前行输核漏出到name文件
变换name 文件名。不需要判断结尾的行。#!/bin/bash
# count the line of the file.
MYDIR="/root/test"
DIRLIST=`ls ${MYDIR}`
SF=()
MF=()
LF=()
for i in ${DIRLIST}
do
LINE=`cat ${MYDIR}/$i | wc -l`
if ((${LINE}<10))
then
SF=(${SF[*]} $i)
elif ((${LINE}>=10)) &&((${LINE}<=100))
then
MF=(${MF[*]} $i)
elif ((${LINE}>100))
then
LF=(${LF[*]} $i)
fi
done
echo Small files: ${SF[*]}
echo Medium files: ${MF[*]}
echo Large files: ${LF[*]}
已测渣兆试正确粗高并无错误,把你要测试的如凳租目录的路径改下即可脚纤和稿本1:
#!/bin/bash
#
#
cd /棚毕tmp/script
cfile=` find -name '*.c' `
hfile=` find -name '*.h' `
for fc in $cfile
do
cfname=`basename -s .c $fc`
cat $fc >/毁孝tmp/scripttest/$cfname.txt
done
for fh in $hfile
do
cp $fh /tmp/scripttest
done
评论列表(0条)