shell 文件操作大全 193条命令

1.创建文件夹
#!/bin/sh
mkdir -m 777 "%%1"

2.创建文件
#!/bin/sh
touch "%%1"

3.删除文件
#!/bin/sh
rm -if "%%1"

4.删除文件夹
#!/bin/sh
rm -rf "%%1"

5.删除一个目录下所有的文件夹
#!/bin/bash
direc="%%1" #$(pwd)
for dir2del in $direc/* ; do
if [ -d $dir2del ]; then
  rm -rf $dir2del
fi
done

6.清空文件夹
#!/bin/bash
direc="%%1" #$(pwd)
rm -if $direc/*
for dir2del in $direc/* ; do
if [ -d $dir2del ]; then
  rm -rf $dir2del
fi
done

7.读取文件
#!/bin/sh
7.1.操作系统默认编码
cat "%%1" | while read line; do
echo $line;
done

7.2.UTF-8编码
cat "%%1" | while read line; do
echo $line;
done

7.3.分块读取
cat "%%1" | while read line; do
echo $line;
done

8.写入文件
#!/bin/sh
cat > "%%1" << EOF
%%2
EOF

tee "%%1" > /dev/null << EOF
%%2
EOF

#sed -i '$a %%2' %%2

9.写入随机文件
#!/bin/sh
cat > "%%1" << EOF
%%2
EOF

tee "%%1" > /dev/null << EOF
%%2
EOF

#sed -i '$a %%2' %%2

10.读取文件属性
#!/bin/bash
file=%%1
file=${file:?'必须给出参数'}
if [ ! -e $file ]; then
    echo "$file 不存在"
    exit 1
fi
if [ -d $file ]; then
    echo "$file 是一个目录"
    if [ -x $file ]; then
        echo "可以"
    else
        echo "不可以"
    fi
    echo "对此进行搜索"  
elif [ -f $file ]; then
    echo "$file 是一个正规文件"
else
    echo "$file不是一个正规文件"
fi
if [ -O $file ]; then
    echo "你是$file的拥有者"
else
    echo "你不是$file的拥有者"
fi
if [ -r $file ]; then
    echo "你对$file拥有"
else
    echo "你并不对$file拥有"
fi
echo "可读权限"
if [ -w $file ]; then
    echo "你对$file拥有"
else
    echo "你并不对$file拥有"
fi
echo "可写权限"
if [ -x $file -a ! -d $file ]; then
    echo "你拥有对$file"
else
    echo "你并不拥有对$file"
fi
echo "可执行的权限"

11.写入文件属性
#!/bin/bash
#修改存放在ext2、ext3、ext4、xfs、ubifs、reiserfs、jfs等文件系统上的文件或目录属性,使用权限超级用户。
#一些功能是由Linux内核版本来支持的,如果Linux内核版本低于2.2,那么许多功能不能实现。同样-D检查压缩文件中的错误的功能,需要2.5.19以上内核才能支持。另外,通过chattr命令修改属性能够提高系统的安全性,但是它并不适合所有的目录。chattr命令不能保护/、/dev、/tmp、/var目录。
chattr [-RV] [-+=AacDdijsSu] [-v version] 文件或目录
  -R:递归处理所有的文件及子目录。
  -V:详细显示修改内容,并打印输出。
  -:失效属性。
  +:激活属性。
  = :指定属性。
  A:Atime,告诉系统不要修改对这个文件的最后访问时间。
  S:Sync,一旦应用程序对这个文件执行了写操作,使系统立刻把修改的结果写到磁盘。
  a:Append Only,系统只允许在这个文件之后追加数据,不允许任何进程覆盖或截断这个文件。如果目录具有这个属性,系统将只允许在这个目录下建立和修改文件,而不允许删除任何文件。
  i:Immutable,系统不允许对这个文件进行任何的修改。如果目录具有这个属性,那么任何的进程只能修改目录之下的文件,不允许建立和删除文件。
  D:检查压缩文件中的错误。
  d:No dump,在进行文件系统备份时,dump程序将忽略这个文件。
  C:Compress,系统以透明的方式压缩这个文件。从这个文件读取时,返回的是解压之后的数据;而向这个文件中写入数据时,数据首先被压缩之后才写入磁盘。
  S:Secure Delete,让系统在删除这个文件时,使用0填充文件所在的区域。
  u:Undelete,当一个应用程序请求删除这个文件,系统会保留其数据块以便以后能够恢复删除这个文件。

12.枚举一个目录中的所有文件夹
#!/bin/bash
OLDIFS=$IFS
IFS=:
for path in $( find "%%1" -type d -printf "%p$IFS")
do
#"$path"
done
IFS=$OLDIFS

13.复制文件夹
#!/bin/sh
cp -rf "%%1" "%%2"

14.复制一个目录下所有的文件夹到另一个目录下
#!/bin/bash
direc="%%1" #$(pwd)
for dir2cp in $direc/* ; do
if [ -d $dir2cp ]; then
  cp $dir2cp "%%2"
fi
done

15.移动文件夹
#!/bin/sh
mv -rf "%%1" "%%2"

16.移动一个目录下所有的文件夹到另一个目录下
#!/bin/bash
direc="%%1" #$(pwd)
for dir2mv in $direc/* ; do
if [ -d $dir2mv ]; then
  mv $dir2mv "%%2"
fi
done

17.以一个文件夹的框架在另一个目录下创建文件夹和空文件
#!/bin/bash
direc="%%1" #$(pwd)
OLDIFS=$IFS
IFS=:
for path in $( find $direc -type d -printf "%p$IFS")
do
mkdir -p "%%2/${path:${#direc}+1}"
done
IFS=$OLDIFS
#cp -a "%%1" "%%2"

表达式 含义
${#string}
{#string}
1,取得字符串长度
string=abc12342341          //等号二边不要有空格
echo ${#string}             //结果11
expr length $string         //结果11
expr "$string" : ".*"       //结果11 分号二边要有空格,这里的:根match的用法差不多2,字符串所在位置
expr index $string '123'    //结果4 字符串对应的下标是从0开始的这个方法让我想起来了js的indexOf,各种语言对字符串的操作方法大方向都差不多,如果有语言基础的话,学习shell会很快的。
3,从字符串开头到子串的最大长度
expr match $string 'abc.*3' //结果9个人觉得这个函数的用处不大,为什么要从开头开始呢。
4,字符串截取
echo ${string:4}      //2342341  从第4位开始截取后面所有字符串
echo ${string:3:3}    //123      从第3位开始截取后面3位
echo ${string:3:6}    //123423   从第3位开始截取后面6位
echo ${string: -4}    //2341  :右边有空格   截取后4位
echo ${string:(-4)}   //2341  同上
expr substr $string 3 3   //123  从第3位开始截取后面3位上面的方法让我想起了,php的substr函数,后面截取的规则是一样的。
5,匹配显示内容
//例3中也有match和这里的match不同,上面显示的是匹配字符的长度,而下面的是匹配的内容
expr match $string '\([a-c]*[0-9]*\)'  //abc12342341
expr $string : '\([a-c]*[0-9]\)'       //abc1
expr $string : '.*\([0-9][0-9][0-9]\)' //341 显示括号中匹配的内容这里括号的用法,是不是根其他的括号用法有相似之处呢,
6,截取不匹配的内容
echo ${string#a*3}     //42341  从$string左边开始,去掉最短匹配子串
echo ${string#c*3}     //abc12342341  这样什么也没有匹配到
echo ${string#*c1*3}   //42341  从$string左边开始,去掉最短匹配子串
echo ${string##a*3}    //41     从$string左边开始,去掉最长匹配子串
echo ${string%3*1}     //abc12342  从$string右边开始,去掉最短匹配子串
echo ${string%%3*1}    //abc12     从$string右边开始,去掉最长匹配子串这里要注意,必须从字符串的第一个字符开始,或者从最后一个开始,
7,匹配并且替换
echo ${string/23/bb}   //abc1bb42341  替换一次
echo ${string//23/bb}  //abc1bb4bb41  双斜杠替换所有匹配
echo ${string/#abc/bb} //bb12342341   #以什么开头来匹配,根php中的^有点像
echo ${string/%41/bb}  //abc123423bb  %以什么结尾来匹配,根php中的$有点像

#!/bin/bash
direc=$(pwd)
for file in "$(direc)/*"
do
if [ "${file##*.}" = "sh" ]; then
xterm -e bash $file
elif [ "${file##*.}" = "bin" ]; then
xterm -e $file
elif [ "${file##*.}" = "run" ]; then
xterm -e $file
elif [ "${file##*.}" = "bundle" ]; then
xterm -e $file
elif [ "${file##*.}" = "pl" ]; then
xterm -e perl $file
elif [ "${file##*.}" = "class" ]; then
xterm -e java ${file%.*}
elif [ "${file##*.}" = "rpm" ]; then
xterm -e rpm -ivh $file
elif [ "${file##*.}" = "rb" ]; then
xterm -e ruby $file
elif [ "${file##*.}" = "py" ]; then
xterm -e python $file
elif [ "${file##*.}" = "jar" ]; then
xterm -e java -jar $file
fi
done
OLDIFS=$IFS
IFS=:
for path in $( find $direc -type d -printf "%p$IFS")
do
for file in `ls $path`
do
if [ "${file##*.}" = "sh" ]; then
xterm -e bash """"$path"/"$file""""
elif [ "${file##*.}" = "bin" ]; then
xterm -e """"$path"/"$file""""
elif [ "${file##*.}" = "run" ]; then
xterm -e """"$path"/"$file""""
elif [ "${file##*.}" = "bundle" ]; then
xterm -e """"$path"/"$file""""
elif [ "${file##*.}" = "pl" ]; then
xterm -e perl """"$path"/"$file""""
elif [ "${file##*.}" = "class" ]; then
xterm -e java """"$path"/"${file%.*}""""
elif [ "${file##*.}" = "rpm" ]; then
xterm -e rpm -ivh """"$path"/"$file""""
elif [ "${file##*.}" = "rb" ]; then
xterm -e ruby """"$path"/"$file""""
elif [ "${file##*.}" = "py" ]; then
xterm -e python """"$path"/"$file""""
elif [ "${file##*.}" = "jar" ]; then
xterm -e java -jar """"$path"/"$file""""
fi
done
done
IFS=$OLDIFS

18.复制文件
#!/bin/sh
cp %%1 %%2

19.复制一个目录下所有的文件到另一个目录
#!/bin/bash
direc="%%1" $(pwd)
for file in "$direc/*"
do
cp "$file" "%%1"
done

20.提取扩展名
#!/bin/sh
%%2=${%%1##.}

21.提取文件名
#!/bin/sh
%%2="$(basename %%1)"

22.提取文件路径
#!/bin/sh
%%2="$(dirname %%1)"

23.替换扩展名
#!/bin/sh
%%3="$(basename %%1)$%%2"

24.追加路径
#!/bin/sh
%%3="$(dirname %%1)/$%%2"

25.移动文件
#!/bin/sh
mv "%%1" "%%2"

26.移动一个目录下所有文件到另一个目录
#!/bin/bash
direc="%%1" #$(pwd)
OLDIFS=$IFS
IFS=:
for file in "$(direc)/*"
do
mv "$file" "%%1"
done
IFS=$OLDIFS

27.指定目录下搜索文件
#!/bin/sh
find -name "%%1"

28.打开文件对话框
#!/bin/sh
%%1="$(Xdialog --fselect '~/' 0 0 2>&1)"

29.文件分割
#!/bin/sh
split -b 2k "%%1"

while read f1 f2 f3
do
    echo $f1 >> f1
    echo $f2 >> f2
    echo $f3 >> f3
done


#!/bin/bash
  linenum=`wc   -l   httperr8007.log|   awk   '{print   $1}'`  
  n1=1  
  file=1  
  while   [   $n1   -lt   $linenum   ]  
  do  
                  n2=`expr   $n1   +   999`  
                  sed   -n   "${n1},   ${n2}p"   httperr8007.log >   file_$file.log    
                  n1=`expr   $n2   +   1`  
                  file=`expr   $file   +   1`  
  done  




其中httperr8007.log为你想分割的大文件,file_$file.log  为分割后的文件,最后为file_1.log,file_2.log,file_3.log……,分割完后的每个文件只有1000行(参数可以自己设置)

split 参数:
-b  :后面可接欲分割成的档案大小,可加单位,例如 b, k, m 等;
-l  :以行数来进行分割;



#按每个文件1000行来分割除

split -l 1000 httperr8007.log httperr

httpaa,httpab,httpac ........

#按照每个文件100K来分割

split -b 100k httperr8007.log http

httpaa,httpab,httpac ........

#!/bin/bash
if [ $# -ne 2 ]; then
echo 'Usage: split file size(in bytes)'
exit
fi

file=$1
size=$2

if [ ! -f $file ]; then
echo "$file doesn't exist"
exit
fi

#TODO: test if $size is a valid integer

filesize=`/bin/ls -l $file | awk '{print $5}'`
echo filesize: $filesize

let pieces=$filesize/$size
let remain=$filesize-$pieces*$size
if [ $remain -gt 0 ]; then
let pieces=$pieces+1
fi
echo pieces: $pieces

i=0
while [ $i -lt $pieces ];
do
echo split: $file.$i:
dd if=$file of=$file.$i bs=$size count=1 skip=$i
let i=$i+1
done

echo "#!/bin/bash" > merge

echo "i=0" >> merge
echo "while [ $i -lt $pieces ];" >> merge
echo "do" >> merge
echo " echo merge: $file.$i" >> merge
echo " if [ ! -f $file.$i ]; then" >> merge
echo " echo merge: $file.$i missed" >> merge
echo " rm -f $file.merged" >> merge
echo " exit" >> merge
echo " fi" >> merge
echo " dd if=$file.$i of=$file.merged bs=$size count=1 seek=$i" >> merge
echo " let i=$i+1" >> merge
echo "done" >> merge
chmod u+x merge'

30.文件合并
#!/bin/sh
cp "%%1"+"%%2" "%%3"

exec 3 exec 4 while read f1 <&3 && read f2 <&4
do
    echo $f1 $f2 >> join.txt
done

#!/bin/bash
if [ $# -ne 2 ]; then
echo 'Usage: split file size(in bytes)'
exit
fi

file=$1
size=$2

if [ ! -f $file ]; then
echo "$file doesn't exist"
exit
fi

#TODO: test if $size is a valid integer

filesize=`/bin/ls -l $file | awk '{print $5}'`
echo filesize: $filesize

let pieces=$filesize/$size
let remain=$filesize-$pieces*$size
if [ $remain -gt 0 ]; then
let pieces=$pieces+1
fi
echo pieces: $pieces

i=0
while [ $i -lt $pieces ];
do
echo split: $file.$i:
dd if=$file of=$file.$i bs=$size count=1 skip=$i
let i=$i+1
done

echo "#!/bin/bash" > merge

echo "i=0" >> merge
echo "while [ $i -lt $pieces ];" >> merge
echo "do" >> merge
echo " echo merge: $file.$i" >> merge
echo " if [ ! -f $file.$i ]; then" >> merge
echo " echo merge: $file.$i missed" >> merge
echo " rm -f $file.merged" >> merge
echo " exit" >> merge
echo " fi" >> merge
echo " dd if=$file.$i of=$file.merged bs=$size count=1 seek=$i" >> merge
echo " let i=$i+1" >> merge
echo "done" >> merge
chmod u+x merge'

31.文件简单加密
#!/bin/bash
#make test && make strings && sudo make install
shc -r -f %%1.sh
#%%1.x
#%%1.x.c

32.文件简单解密
#!/bin/bash
#make test && make strings && sudo make install
shc -r -f %%1.sh
#%%1.x
#%%1.x.c

33.读取ini文件属性
#!/bin/bash
if [ "$%%3" = "" ];then
   sed -n "/\[$%%2\]/,/\[.*\]/{
   /^\[.*\]/d
   /^[ ]*$/d
   s/;.*$//
   p
   }" $1
elif [ "$%%4" = "" ];then
   sed -n "/\[$%%2\]/,/\[.*\]/{
   /^\[.*\]/d
   /^[ ]*$/d
   s/;.*$//
   s/^[ |        ]*$%%3[ | ]*=[ |   ]*\(.*\)[ |     ]*/\1/p
   }" $1
else
       if [ "$%%4" = "#" ];then
            sed "/\[$%%2\]/,/\[.*\]/{
            s/^[ |        ]*$%%3[ |    ]*=.*/ /
            }p" $1 > /tmp/sed$$
            mv /tmp/sed$$ $1
       else
            sed "/\[$2\]/,/\[.*\]/{
            s/^[ |        ]*$%%3[ |    ]*=.*/$%%3=$%%4/
            }p" $1 > /tmp/sed$$
            mv /tmp/sed$$ $%%1
       fi
fi

34.合并一个文件下所有的文件
#!/bin/sh
cat $(ls |grep -E '%%1\.') > %%1

#!/bin/bash
OLDIFS=$IFS
IFS=:
for path in $( find %%1 -type d -printf "%p$IFS")
do
for file in $path/*.c $path/*.cpp
do
if [[ ! "$file" =~ \*.[A-Za-z]+ ]]; then
#"$(path)/$(file)"
fi
done
done
IFS=$OLDIFS

#!/bin/bash
cat <<'EOF'> combine.c
#include
int main()
{
FILE *f1,*f2,*f3;
f1=fopen("a1.txt","r");
f2=fopen("a2.txt","r");
f3=fopen("a3.txt","w");
int a,b;
a=getw(f1);   /*从a1.txt和a2.txt中分别取最小的数a和b*/
b=getw(f2);
while(!feof(f1)&&!feof(f2))  /*两个文件都没结束时,执行循环、比较*/
{
if(a<=b)
{
putw(a,f3);
a=getw(f1);
}
else
{putw(b,f3);
b=getw(f2);
}
   }
if(feof(f1))  /*文件a1.txt结束时,把a2.txt中的数全部输入a3.txt*/
{putw(b,f3);
while((b=getw(f2))!=EOF)
putw(b,f3);
}
if(feof(f2))   /*同上*/
{
putw(a,f3);
while((a=getw(f1))!=EOF)
putw(a,f3);
}
fclose(f1);
fclose(f2);
fclose(f3);
printf("已完成!");
return 0;
}
EOF
gcc -o combine combine.c
if [ $? -eq 0 ]; then
./combine
else
echo 'Compile ERROR'
fi

35.写入ini文件属性
#!/bin/bash
if [ "$%%3" = "" ];then
   sed -n "/\[$%%2\]/,/\[.*\]/{
   /^\[.*\]/d
   /^[ ]*$/d
   s/;.*$//
   p
   }" $1
elif [ "$%%4" = "" ];then
   sed -n "/\[$%%2\]/,/\[.*\]/{
   /^\[.*\]/d
   /^[ ]*$/d
   s/;.*$//
   s/^[ |        ]*$%%3[ | ]*=[ |   ]*\(.*\)[ |     ]*/\1/p
   }" $1
else
       if [ "$%%4" = "#" ];then
            sed "/\[$%%2\]/,/\[.*\]/{
            s/^[ |        ]*$%%3[ |    ]*=.*/ /
            }p" $1 > /tmp/sed$$
            mv /tmp/sed$$ $%%1
       else
            sed "/\[$%%2\]/,/\[.*\]/{
            s/^[ |        ]*$%%3[ |    ]*=.*/$%%3=$%%4/
            }p" $1 > /tmp/sed$$
            mv /tmp/sed$$ $%%1
       fi
fi

36.获得当前路径
#!/bin/sh
%%1=$(pwd)

37.读取XML数据库

如何通过shell命令行读取xml文件中某个属性所对应的值?
例如:
BuildVersion 5
我希望能够通过Unix shell命令对属性键的名称BuildVersion进行查询,返回的结果是5,如何实现呀?
#!/bin/bash
grep BuildVersion|sed 's/.*<.*>\([^<].*\)<.*>.*/\1/'

结果返回的是“BuildVersion”,而不是“5”,如果要查询BuildVersion自动返回数值5应当如何写?

应该没错的。试一下: echo "BuildVersion 5"|grep BuildVersion|sed 's/.*<.*>\([^<].*\)<.*>.*/\1/'我在SL的终端里试,返回值是5

目前需要从xml文件提取数据,想做一个xmlparser.sh
xml 类似这样

  



希望输入 xmlparser.sh a.xml hostip可以返回192.168.0.1


#!/bin/sh

if [ $# -ne 2 ];then
   echo "Usage: $0 "
   exit 0
fi

grep $2 $1|awk '{print $2}'|grep -o "[0-9.]*"



grep $2 $1|awk '{print $2}'|grep -o "[0-9.]*"
改成
grep $2 $1|awk '{print $2}'|grep -Eo "[0-9.]+"
楼上这个有问题,如果我要得到的是

  

中的sharename,那么,呵呵,就错了

我觉得应该先定位到第二个参数“$2”的位置,然后再提取“=”后面的内容

这里有个完整的实现:
Parse Simple XML Files using Bash – Extract Name Value Pairs and Attributes
http://www.humbug.in/2010/parse-simple-xml-files-using-bash-extract-name-value-pairs-and-attributes/


不过需要安装xmllint.

设计到对多个xml文件进行element的读取和列表。有人做过么?
举个例子,
多个xml文件里面都有

        xxx</titlel><br style="word-wrap:break-word"> </article><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 通过shell读取,然后合并到一起,再生成一个新的xml,但是其他元素不变。<br style="word-wrap:break-word"> <article><br style="word-wrap:break-word">         <title>aaa</titlel><br style="word-wrap:break-word"> </article><br style="word-wrap:break-word"> <article><br style="word-wrap:break-word">         <title>bbb</titlel><br style="word-wrap:break-word"> </article><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 如果格式异常简单,没有特例,那么可以用shell实现<br style="word-wrap:break-word"> 如果有可能格式复杂,因为shell的命令所使用的正则表达式都不支持跨行匹配,所以用shell来解决这个问题就绕圈子了。<br style="word-wrap:break-word"> 用perl来作这个工作最直接、简单。perl的XML:DOM模块是专门处理XML文件的。<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 偶倒是觉得,用PHP写Scripts也很方便,功能强大,而且,跨平台,<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> sed -n '/<article>/{<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> N;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> /\n[[:space:]]*<title>/{<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     N;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     /<article>.*<\/article>/p<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     }<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> D;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> n<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> }'<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 这小段代码能把一个xml文件中,你要的东西拿出来.<br style="word-wrap:break-word"> 你可以用for file in $*把这些信息都>>tmpfile中.<br style="word-wrap:break-word"> 然后用sed 在指定文件的指定位置用r命令把tmpfile粘贴进来~~~~<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 大思路如此^_^  我想有这个东西(只要能正确的跑出结果)后面就不难了吧...<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Name<br style="word-wrap:break-word"> xmllint — command line XML tool<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Synopsis<br style="word-wrap:break-word"> xmllint [[--version] | [--debug] | [--shell] | [--debugent] | [--copy] | [--recover] | [--noent] | [--noout] | [--nonet] | [--htmlout] | [--nowrap] | [--valid] | [--postvalid] | [--dtdvalid URL] | [--dtdvalidfpi FPI] | [--timing] | [--output file] | [--repeat] | [--insert] | [--compress] | [--html] | [--xmlout] | [--push] | [--memory] | [--maxmem nbbytes] | [--nowarning] | [--noblanks] | [--nocdata] | [--format] | [--encode encoding] | [--dropdtd] | [--nsclean] | [--testIO] | [--catalogs] | [--nocatalogs] | [--auto] | [--xinclude] | [--noxincludenode] | [--loaddtd] | [--dtdattr] | [--stream] | [--walker] | [--pattern patternvalue] | [--chkregister] | [--relaxng] | [--schema] | [--c14n]] [xmlfile]<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Introduction<br style="word-wrap:break-word"> The xmllint program parses one or more XML files, specified on the command line as xmlfile. It prints various types of output, depending upon the options selected. It is useful for detecting errors both in XML code and in the XML parser itself.<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> It is included in libxml2.<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Options<br style="word-wrap:break-word"> --version<br style="word-wrap:break-word"> Display the version of libxml2 used.<br style="word-wrap:break-word"> --debug<br style="word-wrap:break-word"> Parse a file and output an annotated tree of the in-memory version of the document.<br style="word-wrap:break-word"> --shell<br style="word-wrap:break-word"> Run a navigating shell. Details on available commands in shell mode are below.<br style="word-wrap:break-word"> --debugent<br style="word-wrap:break-word"> Debug the entities defined in the document.<br style="word-wrap:break-word"> --copy<br style="word-wrap:break-word"> Test the internal copy implementation.<br style="word-wrap:break-word"> --recover<br style="word-wrap:break-word"> Output any parsable portions of an invalid document.<br style="word-wrap:break-word"> --noent<br style="word-wrap:break-word"> Substitute entity values for entity references. By default, xmllint leaves entity references in place.<br style="word-wrap:break-word"> --nocdata<br style="word-wrap:break-word"> Substitute CDATA section by equivalent text nodes.<br style="word-wrap:break-word"> --nsclean<br style="word-wrap:break-word"> Remove redundant namespace declarations.<br style="word-wrap:break-word"> --noout<br style="word-wrap:break-word"> Suppress output. By default, xmllint outputs the result tree.<br style="word-wrap:break-word"> --htmlout<br style="word-wrap:break-word"> Output results as an HTML file. This causes xmllint to output the necessary HTML tags surrounding the result tree output so the results can be displayed in a browser.<br style="word-wrap:break-word"> --nowrap<br style="word-wrap:break-word"> Do not output HTML doc wrapper.<br style="word-wrap:break-word"> --valid<br style="word-wrap:break-word"> Determine if the document is a valid instance of the included Document Type Definition (DTD). A DTD to be validated against also can be specified at the command line using the --dtdvalid option. By default, xmllint also checks to determine if the document is well-formed.<br style="word-wrap:break-word"> --postvalid<br style="word-wrap:break-word"> Validate after parsing is completed.<br style="word-wrap:break-word"> --dtdvalid URL<br style="word-wrap:break-word"> Use the DTD specified by URL for validation.<br style="word-wrap:break-word"> --dtdvalidfpi FPI<br style="word-wrap:break-word"> Use the DTD specified by the Public Identifier FPI for validation, note that this will require a Catalog exporting that Public Identifier to work.<br style="word-wrap:break-word"> --timing<br style="word-wrap:break-word"> Output information about the time it takes xmllint to perform the various steps.<br style="word-wrap:break-word"> --output file<br style="word-wrap:break-word"> Define a file path where xmllint will save the result of parsing. Usually the programs build a tree and save it on stdout, with this option the result XML instance will be saved onto a file.<br style="word-wrap:break-word"> --repeat<br style="word-wrap:break-word"> Repeat 100 times, for timing or profiling.<br style="word-wrap:break-word"> --insert<br style="word-wrap:break-word"> Test for valid insertions.<br style="word-wrap:break-word"> --compress<br style="word-wrap:break-word"> Turn on gzip compression of output.<br style="word-wrap:break-word"> --html<br style="word-wrap:break-word"> Use the HTML parser.<br style="word-wrap:break-word"> --xmlout<br style="word-wrap:break-word"> Used in conjunction with --html. Usually when HTML is parsed the document is saved with the HTML serializer, but with this option the resulting document is saved with the XML serializer. This is primarily used to generate XHTML from HTML input.<br style="word-wrap:break-word"> --push<br style="word-wrap:break-word"> Use the push mode of the parser.<br style="word-wrap:break-word"> --memory<br style="word-wrap:break-word"> Parse from memory.<br style="word-wrap:break-word"> --maxmem nnbytes<br style="word-wrap:break-word"> Test the parser memory support. nnbytes is the maximum number of bytes the library is allowed to allocate. This can also be used to make sure batch processing of XML files will not exhaust the virtual memory of the server running them.<br style="word-wrap:break-word"> --nowarning<br style="word-wrap:break-word"> Do not emit warnings from the parser and/or validator.<br style="word-wrap:break-word"> --noblanks<br style="word-wrap:break-word"> Drop ignorable blank spaces.<br style="word-wrap:break-word"> --format<br style="word-wrap:break-word"> Reformat and reindent the output. The $XMLLINT_INDENT environment variable controls the indentation (default value is two spaces " ").<br style="word-wrap:break-word"> --testIO<br style="word-wrap:break-word"> Test user input/output support.<br style="word-wrap:break-word"> --encode encoding<br style="word-wrap:break-word"> Output in the given encoding.<br style="word-wrap:break-word"> --catalogs<br style="word-wrap:break-word"> Use the catalogs from $SGML_CATALOG_FILES. Otherwise /etc/xml/catalog is used by default.<br style="word-wrap:break-word"> --nocatalogs<br style="word-wrap:break-word"> Do not use any catalogs.<br style="word-wrap:break-word"> --auto<br style="word-wrap:break-word"> Generate a small document for testing purposes.<br style="word-wrap:break-word"> --xinclude<br style="word-wrap:break-word"> Do XInclude processing.<br style="word-wrap:break-word"> --noxincludenode<br style="word-wrap:break-word"> Do XInclude processing but do not generate XInclude start and end nodes.<br style="word-wrap:break-word"> --loaddtd<br style="word-wrap:break-word"> Fetch external DTD.<br style="word-wrap:break-word"> --dtdattr<br style="word-wrap:break-word"> Fetch external DTD and populate the tree with inherited attributes.<br style="word-wrap:break-word"> --dropdtd<br style="word-wrap:break-word"> Remove DTD from output.<br style="word-wrap:break-word"> --stream<br style="word-wrap:break-word"> Use streaming API - useful when used in combination with --relaxng or --valid options for validation of files that are too large to be held in memory.<br style="word-wrap:break-word"> --walker<br style="word-wrap:break-word"> Test the walker module, which is a reader interface but for a document tree, instead of using the reader API on an unparsed document it works on a existing in-memory tree. Used in debugging.<br style="word-wrap:break-word"> --chkregister<br style="word-wrap:break-word"> Turn on node registration. Useful for developers testing libxml2 node tracking code.<br style="word-wrap:break-word"> --pattern patternvalue<br style="word-wrap:break-word"> Used to exercise the pattern recognition engine, which can be used with the reader interface to the parser. It allows to select some nodes in the document based on an XPath (subset) expression. Used for debugging.<br style="word-wrap:break-word"> --relaxng schema<br style="word-wrap:break-word"> Use RelaxNG file named schema for validation.<br style="word-wrap:break-word"> --schema schema<br style="word-wrap:break-word"> Use a W3C XML Schema file named schema for validation.<br style="word-wrap:break-word"> --c14n<br style="word-wrap:break-word"> Use the W3C XML Canonicalisation (C14N) to serialize the result of parsing to stdout. It keeps comments in the result.<br style="word-wrap:break-word"> Shell<br style="word-wrap:break-word"> xmllint offers an interactive shell mode invoked with the --shell command. Available commands in shell mode include:<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> base<br style="word-wrap:break-word"> display XML base of the node<br style="word-wrap:break-word"> bye<br style="word-wrap:break-word"> leave shell<br style="word-wrap:break-word"> cat node<br style="word-wrap:break-word"> Display node if given or current node.<br style="word-wrap:break-word"> cd path<br style="word-wrap:break-word"> Change the current node to path (if given and unique) or root if no argument given.<br style="word-wrap:break-word"> dir path<br style="word-wrap:break-word"> Dumps information about the node (namespace, attributes, content).<br style="word-wrap:break-word"> du path<br style="word-wrap:break-word"> Show the structure of the subtree under path or the current node.<br style="word-wrap:break-word"> exit<br style="word-wrap:break-word"> Leave the shell.<br style="word-wrap:break-word"> help<br style="word-wrap:break-word"> Show this help.<br style="word-wrap:break-word"> free<br style="word-wrap:break-word"> Display memory usage.<br style="word-wrap:break-word"> load name<br style="word-wrap:break-word"> Load a new document with the given name.<br style="word-wrap:break-word"> ls path<br style="word-wrap:break-word"> List contents of path (if given) or the current directory.<br style="word-wrap:break-word"> pwd<br style="word-wrap:break-word"> Display the path to the current node.<br style="word-wrap:break-word"> quit<br style="word-wrap:break-word"> Leave the shell.<br style="word-wrap:break-word"> save name<br style="word-wrap:break-word"> Saves the current document to name if given or to the original name.<br style="word-wrap:break-word"> validate<br style="word-wrap:break-word"> Check the document for error.<br style="word-wrap:break-word"> write name<br style="word-wrap:break-word"> Write the current node to the given filename.<br style="word-wrap:break-word"> Catalogs<br style="word-wrap:break-word"> Catalog behavior can be changed by redirecting queries to the user's own set of catalogs. This can be done by setting the XML_CATALOG_FILES environment variable to a list of catalogs. An empty one should deactivate loading the default /etc/xml/catalog default catalog.<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Debugging Catalogs<br style="word-wrap:break-word"> Setting the environment variable XML_DEBUG_CATALOG using the command "export XML_DEBUG_CATALOG=" outputs debugging information related to catalog operations.<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Error Return Codes<br style="word-wrap:break-word"> On the completion of execution, Xmllint returns the following error codes:<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 0<br style="word-wrap:break-word"> No error<br style="word-wrap:break-word"> 1<br style="word-wrap:break-word"> Unclassified<br style="word-wrap:break-word"> 2<br style="word-wrap:break-word"> Error in DTD<br style="word-wrap:break-word"> 3<br style="word-wrap:break-word"> Validation error<br style="word-wrap:break-word"> 4<br style="word-wrap:break-word"> Validation error<br style="word-wrap:break-word"> 5<br style="word-wrap:break-word"> Error in schema compilation<br style="word-wrap:break-word"> 6<br style="word-wrap:break-word"> Error writing output<br style="word-wrap:break-word"> 7<br style="word-wrap:break-word"> Error in pattern (generated when [--pattern] option is used)<br style="word-wrap:break-word"> 8<br style="word-wrap:break-word"> Error in Reader registration (generated when [--chkregister] option is used)<br style="word-wrap:break-word"> 9<br style="word-wrap:break-word"> Out of memory error<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Parse Simple XML Files using Bash – Extract Name Value Pairs and Attributes<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 2 Comments<br style="word-wrap:break-word"> 1<br style="word-wrap:break-word"> Tweet<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Pratik Sinha | July 31, 2010<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> I have written up a simple routine par***ML to parse simple XML files to extract unique name values pairs and their attributes. The script extracts all xml tags of the format <abc arg1="hello">xyz</abc> and dynamically creates bash variables which hold values of the attributes as well as the elements. This is a good solution, if you don’t wish to use xpath for some simple xml files. However you will need xmllint installed on your system to use the script. Here’s a sample script which uses the par***ML function<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> xmlFile=$1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> function par***ML() {<br style="word-wrap:break-word">   elemList=( $(cat $xmlFile | tr '\n' ' ' | XMLLINT_INDENT="" xmllint --format - | /bin/grep -e "</.*>$" | while read line; do \<br style="word-wrap:break-word">     echo $line | sed -e 's/^.*<\///' | cut -d '>' -f 1; \<br style="word-wrap:break-word">   done) )<br style="word-wrap:break-word"> <br style="word-wrap:break-word">   totalNoOfTags=${#elemList[@]}; ((totalNoOfTags--))<br style="word-wrap:break-word">   suffix=$(echo ${elemList[$totalNoOfTags]} | tr -d '</>')<br style="word-wrap:break-word">   suffix="${suffix}_"<br style="word-wrap:break-word"> <br style="word-wrap:break-word">   for (( i = 0 ; i < ${#elemList[@]} ; i++ )); do<br style="word-wrap:break-word">     elem=${elemList[$i]}<br style="word-wrap:break-word">     elemLine=$(cat $xmlFile | tr '\n' ' ' | XMLLINT_INDENT="" xmllint --format - | /bin/grep "</$elem>")<br style="word-wrap:break-word">     echo $elemLine | grep -e "^</[^ ]*>$" 1>/dev/null 2>&1<br style="word-wrap:break-word">     if [ "0" = "$?" ]; then<br style="word-wrap:break-word">       continue<br style="word-wrap:break-word">     fi<br style="word-wrap:break-word">     elemVal=$(echo $elemLine | tr '\011' '\040'| sed -e 's/^[ ]*//' -e 's/^<.*>\([^<].*\)<.*>$/\1/' | sed -e 's/^[ ]*//' | sed -e 's/[ ]*$//')<br style="word-wrap:break-word">     xmlElem="${suffix}$(echo $elem | sed 's/-/_/g')"<br style="word-wrap:break-word">     eval ${xmlElem}=`echo -ne \""${elemVal}"\"`<br style="word-wrap:break-word">     attrList=($(cat $xmlFile | tr '\n' ' ' | XMLLINT_INDENT="" xmllint --format - | /bin/grep "</$elem>" | tr '\011' '\040' | sed -e 's/^[ ]*//' | cut -d '>' -f 1  | sed -e 's/^<[^ ]*//' | tr "'" '"' | tr '"' '\n'  | tr '=' '\n' | sed -e 's/^[ ]*//' | sed '/^$/d' | tr '\011' '\040' | tr ' ' '>'))<br style="word-wrap:break-word">     for (( j = 0 ; j < ${#attrList[@]} ; j++ )); do<br style="word-wrap:break-word">       attr=${attrList[$j]}<br style="word-wrap:break-word">       ((j++))<br style="word-wrap:break-word">       attrVal=$(echo ${attrList[$j]} | tr '>' ' ')<br style="word-wrap:break-word">       attrName=`echo -ne ${xmlElem}_${attr}`<br style="word-wrap:break-word">       eval ${attrName}=`echo -ne \""${attrVal}"\"`<br style="word-wrap:break-word">     done<br style="word-wrap:break-word">   done<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> par***ML<br style="word-wrap:break-word"> echo "$status_xyz |  $status_abc |  $status_pqr" #Variables for each  XML ELement<br style="word-wrap:break-word"> echo "$status_xyz_arg1 |  $status_abc_arg2 |  $status_pqr_arg3 | $status_pqr_arg4" #Variables for each XML Attribute<br style="word-wrap:break-word"> echo ""<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #All the variables that were produced by the par***ML function<br style="word-wrap:break-word"> set | /bin/grep -e "^$suffix"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> The XML File used for the above script example is:<br style="word-wrap:break-word"> <?xml version="1.0"?><br style="word-wrap:break-word"> <status><br style="word-wrap:break-word">   <xyz arg1="1"> a </xyz><br style="word-wrap:break-word">   <abc arg2="2"> p </abc><br style="word-wrap:break-word">   <pqr arg3="3" arg4="a phrase"> x </pqr><br style="word-wrap:break-word"> </status><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> The root tag, which in this case is “status”, is used as a suffix for all variables. Once the XML file is passed to the function, it dynamically creates the variables $status_xyz, $status_abc, $status_pqr, $status_xyz_arg1, $status_abc_arg2, $status_pqr_arg3 and $status_pqr_arg4.<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> The output when the script is ran with the xml file as an argument is<br style="word-wrap:break-word"> @$ bash  par***ML.sh test.xml<br style="word-wrap:break-word"> a |  p |  x<br style="word-wrap:break-word"> 1 |  2 |  3 | a phrase<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> status_abc=p<br style="word-wrap:break-word"> status_abc_arg2=2<br style="word-wrap:break-word"> status_pqr=x<br style="word-wrap:break-word"> status_pqr_arg3=3<br style="word-wrap:break-word"> status_pqr_arg4='a phrase'<br style="word-wrap:break-word"> status_xyz=a<br style="word-wrap:break-word"> status_xyz_arg1=1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> This script won’t work for XML files like the one below with duplicate element names.<br style="word-wrap:break-word"> <?xml version="1.0"?><br style="word-wrap:break-word"> <status><br style="word-wrap:break-word">   <test arg1="1"> a </test><br style="word-wrap:break-word">   <test arg2="2"> p </test><br style="word-wrap:break-word">   <test arg3="3" arg4="a phrase"> x </test><br style="word-wrap:break-word"> </status><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> This script also won’t be able to extract attributes of elements without any CDATA. For eg, the script won’t be able to create variables corresponding to <test arg1="1">. It will only create the variables corresponding to <test1 arg2="2">abc</test1>.<br style="word-wrap:break-word"> <?xml version="1.0"?><br style="word-wrap:break-word"> <status><br style="word-wrap:break-word">   <test arg1="1"><br style="word-wrap:break-word">     <test1 arg2="2">abc</test1><br style="word-wrap:break-word">   </test><br style="word-wrap:break-word"> </status><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 38.写入XML数据库<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 39.ZIP压缩文件<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> zip -r "/%%1" "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 40.ZIP解压缩<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> unzip -x "/%%1" "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 41.获得应用程序完整路径<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 42.ZIP压缩文件夹<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 43.递归删除目录下的文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rm -if "%%1/*"<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find %%1 -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> for file in $path/*.c $path/*.cpp<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [[ ! "$file" =~ \*.[A-Za-z]+ ]]; then<br style="word-wrap:break-word"> #"$(path)/$(file)"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 44.IDEA加密算法<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 45.RC6算法<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> cat <<'EOF'> rc6.c<br style="word-wrap:break-word"> #include<stdio.h><br style="word-wrap:break-word"> /* Timing data for RC6 (rc6.c)<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 128 bit key:<br style="word-wrap:break-word"> Key Setup:    1632 cycles<br style="word-wrap:break-word"> Encrypt:       270 cycles =    94.8 mbits/sec<br style="word-wrap:break-word"> Decrypt:       226 cycles =   113.3 mbits/sec<br style="word-wrap:break-word"> Mean:          248 cycles =   103.2 mbits/sec<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 192 bit key:<br style="word-wrap:break-word"> Key Setup:    1885 cycles<br style="word-wrap:break-word"> Encrypt:       267 cycles =    95.9 mbits/sec<br style="word-wrap:break-word"> Decrypt:       235 cycles =   108.9 mbits/sec<br style="word-wrap:break-word"> Mean:          251 cycles =   102.0 mbits/sec<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 256 bit key:<br style="word-wrap:break-word"> Key Setup:    1877 cycles<br style="word-wrap:break-word"> Encrypt:       270 cycles =    94.8 mbits/sec<br style="word-wrap:break-word"> Decrypt:       227 cycles =   112.8 mbits/sec<br style="word-wrap:break-word"> Mean:          249 cycles =   103.0 mbits/sec<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> */<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #include "../std_defs.h"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> static char *alg_name[] = { "rc6", "rc6.c", "rc6" };<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> char **cipher_name()<br style="word-wrap:break-word"> {<br style="word-wrap:break-word">     return alg_name;<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #define f_rnd(i,a,b,c,d)                    \<br style="word-wrap:break-word">         u = rotl(d * (d + d + 1), 5);       \<br style="word-wrap:break-word">         t = rotl(b * (b + b + 1), 5);       \<br style="word-wrap:break-word">         a = rotl(a ^ t, u) + l_key;      \<br style="word-wrap:break-word">         c = rotl(c ^ u, t) + l_key[i + 1]<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #define i_rnd(i,a,b,c,d)                    \<br style="word-wrap:break-word">         u = rotl(d * (d + d + 1), 5);       \<br style="word-wrap:break-word">         t = rotl(b * (b + b + 1), 5);       \<br style="word-wrap:break-word">         c = rotr(c - l_key[i + 1], t) ^ u;  \<br style="word-wrap:break-word">         a = rotr(a - l_key, u) ^ t<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> u4byte  l_key[44];  /* storage for the key schedule         */<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> /* initialise the key schedule from the user supplied key   */<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> u4byte *set_key(const u4byte in_key[], const u4byte key_len)<br style="word-wrap:break-word"> {   u4byte  i, j, k, a, b, l[8], t;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     l_key[0] = 0xb7e15163;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     for(k = 1; k < 44; ++k)<br style="word-wrap:break-word">        <br style="word-wrap:break-word">         l_key[k] = l_key[k - 1] + 0x9e3779b9;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     for(k = 0; k < key_len / 32; ++k)<br style="word-wrap:break-word"> <br style="word-wrap:break-word">         l[k] = in_key[k];<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     t = (key_len / 32) - 1; // t = (key_len / 32);<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     a = b = i = j = 0;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     for(k = 0; k < 132; ++k)<br style="word-wrap:break-word">     {   a = rotl(l_key + a + b, 3); b += a;<br style="word-wrap:break-word">         b = rotl(l[j] + b, b);<br style="word-wrap:break-word">         l_key = a; l[j] = b;<br style="word-wrap:break-word">         i = (i == 43 ? 0 : i + 1); // i = (i + 1) % 44; <br style="word-wrap:break-word">         j = (j == t ? 0 : j + 1);  // j = (j + 1) % t;<br style="word-wrap:break-word">     }<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     return l_key;<br style="word-wrap:break-word"> };<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> /* encrypt a block of text  */<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> void encrypt(const u4byte in_blk[4], u4byte out_blk[4])<br style="word-wrap:break-word"> {   u4byte  a,b,c,d,t,u;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     a = in_blk[0]; b = in_blk[1] + l_key[0];<br style="word-wrap:break-word">     c = in_blk[2]; d = in_blk[3] + l_key[1];<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     f_rnd( 2,a,b,c,d); f_rnd( 4,b,c,d,a);<br style="word-wrap:break-word">     f_rnd( 6,c,d,a,b); f_rnd( 8,d,a,b,c);<br style="word-wrap:break-word">     f_rnd(10,a,b,c,d); f_rnd(12,b,c,d,a);<br style="word-wrap:break-word">     f_rnd(14,c,d,a,b); f_rnd(16,d,a,b,c);<br style="word-wrap:break-word">     f_rnd(18,a,b,c,d); f_rnd(20,b,c,d,a);<br style="word-wrap:break-word">     f_rnd(22,c,d,a,b); f_rnd(24,d,a,b,c);<br style="word-wrap:break-word">     f_rnd(26,a,b,c,d); f_rnd(28,b,c,d,a);<br style="word-wrap:break-word">     f_rnd(30,c,d,a,b); f_rnd(32,d,a,b,c);<br style="word-wrap:break-word">     f_rnd(34,a,b,c,d); f_rnd(36,b,c,d,a);<br style="word-wrap:break-word">     f_rnd(38,c,d,a,b); f_rnd(40,d,a,b,c);<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     out_blk[0] = a + l_key[42]; out_blk[1] = b;<br style="word-wrap:break-word">     out_blk[2] = c + l_key[43]; out_blk[3] = d;<br style="word-wrap:break-word"> };<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> /* decrypt a block of text  */<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> void decrypt(const u4byte in_blk[4], u4byte out_blk[4])<br style="word-wrap:break-word"> {   u4byte  a,b,c,d,t,u;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     d = in_blk[3]; c = in_blk[2] - l_key[43];<br style="word-wrap:break-word">     b = in_blk[1]; a = in_blk[0] - l_key[42];<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     i_rnd(40,d,a,b,c); i_rnd(38,c,d,a,b);<br style="word-wrap:break-word">     i_rnd(36,b,c,d,a); i_rnd(34,a,b,c,d);<br style="word-wrap:break-word">     i_rnd(32,d,a,b,c); i_rnd(30,c,d,a,b);<br style="word-wrap:break-word">     i_rnd(28,b,c,d,a); i_rnd(26,a,b,c,d);<br style="word-wrap:break-word">     i_rnd(24,d,a,b,c); i_rnd(22,c,d,a,b);<br style="word-wrap:break-word">     i_rnd(20,b,c,d,a); i_rnd(18,a,b,c,d);<br style="word-wrap:break-word">     i_rnd(16,d,a,b,c); i_rnd(14,c,d,a,b);<br style="word-wrap:break-word">     i_rnd(12,b,c,d,a); i_rnd(10,a,b,c,d);<br style="word-wrap:break-word">     i_rnd( 8,d,a,b,c); i_rnd( 6,c,d,a,b);<br style="word-wrap:break-word">     i_rnd( 4,b,c,d,a); i_rnd( 2,a,b,c,d);<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     out_blk[3] = d - l_key[1]; out_blk[2] = c;<br style="word-wrap:break-word">     out_blk[1] = b - l_key[0]; out_blk[0] = a;<br style="word-wrap:break-word"> };<br style="word-wrap:break-word"> int main()<br style="word-wrap:break-word"> {<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> return 0;<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> EOF<br style="word-wrap:break-word"> gcc -o rc6 rc6.c<br style="word-wrap:break-word"> if [ $? -eq 0 ]; then<br style="word-wrap:break-word"> ./combine<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> echo 'Compile ERROR'<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 46.Grep<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> grep -qE %%1 %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 47.直接创建多级目录<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> mkdir -p %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 48.批量重命名<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find $PWD -type f -name '*\.cpp' |sed s/'\.cpp'//g|awk '{MV = "mv"};{C = "\.c"};{ CPP="\.cpp"}; {print MV, $1 CPP , $1 C}'|sh<br style="word-wrap:break-word"> ls | awk -F '-' '{print "mv "$0" "$2}' #去掉带'-'的前缀<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 49.文本查找替换<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> sed -e 's:%%2:%%3:g' %%1<br style="word-wrap:break-word"> #sed -e 's/%%2/%%3/g' %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 50.文件关联<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 51.批量转换编码从GB2312到Unicode<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> scode="gbk"<br style="word-wrap:break-word"> dcode="ucs2"<br style="word-wrap:break-word"> for FILE in $(find $(pwd) -type f)<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> TMP_file=$(mktemp -p $(pwd))<br style="word-wrap:break-word"> if [ -f $FILE ]; then<br style="word-wrap:break-word"> Fright=$(stat -c %a $FILE)<br style="word-wrap:break-word"> Fuser=$(stat -c %U $FILE)<br style="word-wrap:break-word"> Fgrp=$(stat -c %G $FILE)<br style="word-wrap:break-word"> iconv -f $scode -t $dcode $FILE -o $TMP_file<br style="word-wrap:break-word"> mv $TMP_file $FILE<br style="word-wrap:break-word"> chmod $Fright $FILE<br style="word-wrap:break-word"> chown $Fuser.$Fgrp $FILE<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 52.设置JDK环境变量<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find "$PWD" -type f \( -iname '*.bin' \) -print0 | xargs -0 chmod +x<br style="word-wrap:break-word"> find -type f \( -iname '*.bin' \) -print |<br style="word-wrap:break-word"> while read filename<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     case "$filename" in<br style="word-wrap:break-word">     *.bin)<br style="word-wrap:break-word">         xterm -e "$filename" && rm -if "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     esac<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=$'\n'<br style="word-wrap:break-word"> for line in `cat ~/.bashrc`<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [[ "$line" =~ .*export.* ]]; then<br style="word-wrap:break-word">     if [[ "$line" =~ .*JAVA_HOME=.* ]]; then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]]; then<br style="word-wrap:break-word">        javahome=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     fi<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [[ "$line" =~ export\ PATH=\$PATH:\$JAVA_HOME/bin:\$JAVA_HOME/jre/bin$ ]];then<br style="word-wrap:break-word">     javapath=$line<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [[ "$line" =~ export\ CLASSPATH=.:\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib$ ]];then<br style="word-wrap:break-word">     classpath=$line<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> if [ ! -n "$javahome" ]; then<br style="word-wrap:break-word"> sed -i '$a export JAVA_HOME='$(pwd)'/jdk1.6.0_25' ~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${javahome//\\/\\\\}':export JAVA_HOME='$(pwd)'/jdk1.6.0_32:g' ~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$javapath" ]; then<br style="word-wrap:break-word"> sed -i '$a export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin' ~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$classpath" ]; then<br style="word-wrap:break-word"> sed -i '$a export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' ~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> shift<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=$'\n'<br style="word-wrap:break-word"> for line in `cat ~/TestBash.txt` #~/.bashrc<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">   if [[ "$line" =~ .*export.* ]]; then<br style="word-wrap:break-word">     if [[ "$line" =~ export\ CLASSPATH=.:\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib$ ]]; then<br style="word-wrap:break-word">       classpath=$line<br style="word-wrap:break-word">     elif [[ "$line" =~ export\ PATH=\$PATH:\$CATALINA_HOME/bin$ ]]; then<br style="word-wrap:break-word">       jbosspath=$line<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word">     if [[ "$line" =~ .*JAVA_HOME=.* ]]; then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]];then<br style="word-wrap:break-word">        javahome=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     elif [[ "$line" =~ .*CATALINA_HOME=.* ]];then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]];then<br style="word-wrap:break-word">        catalinahome=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     elif [[ "$line" =~ .*TOMCAT_HOME=.* ]];then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]];then<br style="word-wrap:break-word">        tomcathome=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     elif [[ "$line" =~ .*CATALINA_BASE=.* ]];then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]];then<br style="word-wrap:break-word">        catalinabase=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     elif [[ "$line" =~ .*JBOSS_HOME=.* ]];then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]];then<br style="word-wrap:break-word">        jbosshome=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     fi<br style="word-wrap:break-word">   elif [[ "$line" =~ ^PATH=\$PATH:\$JAVA_HOME/bin:\$JAVA_HOME/jre/bin$ ]];then<br style="word-wrap:break-word">     javapath=$line<br style="word-wrap:break-word">   fi<br style="word-wrap:break-word">   if [[ "$line" =~ export\ CLASSPATH=.:\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib$ ]];then<br style="word-wrap:break-word">     classpath=$line<br style="word-wrap:break-word">   fi<br style="word-wrap:break-word">   if [[ "$line" =~ export\ PATH=\$PATH:\$JBOSS_HOME/bin$ ]];then<br style="word-wrap:break-word">     jbosspath=$line<br style="word-wrap:break-word">   fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> if [ ! -n "$javahome" ]; then<br style="word-wrap:break-word"> sed -i '$a export JAVA_HOME='$(pwd)'/jdk1.6.0_24' ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${javahome//\\/\\\\}':export JAVA_HOME='$(pwd)'/jdk1.6.0_24:g' ~/TestBash.txt<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$javapath" ]; then<br style="word-wrap:break-word"> sed -i '$a PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin' ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$classpath" ]; then<br style="word-wrap:break-word"> sed -i '$a export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$catalinahome" ]; then<br style="word-wrap:break-word"> sed -i '$a export CATALINA_HOME='$(pwd) ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${catalinahome//\\/\\\\}':export CATALINA_HOME='$(pwd)':g' ~/TestBash.txt<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$tomcathome" ]; then<br style="word-wrap:break-word"> sed -i '$a export TOMCAT_HOME='$(pwd) ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${tomcathome//\\/\\\\}':export TOMCAT_HOME='$(pwd)':g' ~/TestBash.txt<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$catalinabase" ]; then<br style="word-wrap:break-word"> sed -i '$a export CATALINA_BASE='$(pwd) ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${catalinabase//\\/\\\\}':export CATALINA_BASE='$(pwd)':g' ~/TestBash.txt<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$jbosshome" ]; then<br style="word-wrap:break-word"> sed -i '$a export JBOSS_HOME='$(pwd) ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${jbosshome//\\/\\\\}':export JBOSS_HOME='$(pwd)':g' ~/TestBash.txt<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$jbosspath" ]; then<br style="word-wrap:break-word"> sed -i '$a export PATH=$PATH:$CATALINA_HOME/bin' ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 53.批量转换编码从Unicode到GB2312<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> scode="ucs2"<br style="word-wrap:break-word"> dcode="gbk"<br style="word-wrap:break-word"> for FILE in $(find $(pwd) -type f)<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> TMP_file=$(mktemp -p $(pwd))<br style="word-wrap:break-word"> if [ -f $FILE ]; then<br style="word-wrap:break-word"> Fright=$(stat -c %a $FILE)<br style="word-wrap:break-word"> Fuser=$(stat -c %U $FILE)<br style="word-wrap:break-word"> Fgrp=$(stat -c %G $FILE)<br style="word-wrap:break-word"> iconv -f $scode -t $dcode $FILE -o $TMP_file<br style="word-wrap:break-word"> mv $TMP_file $FILE<br style="word-wrap:break-word"> chmod $Fright $FILE<br style="word-wrap:break-word"> chown $Fuser.$Fgrp $FILE<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 54.删除空文件夹<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rmdir -p %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 55.GB2312文件转UTF-8格式<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> iconv -f gbk -t utf8 %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 56.UTF-8文件转GB2312格式<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> iconv -f utf8 -t  gbk %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 57.获取文件路径的父路径<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> %%1=basename $PWD<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 58.Unicode文件转UTF-8格式<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> iconv -f ucs2 -t  utf-8 %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 59.CRC循环冗余校验<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> cat <<'EOF'> crc.c<br style="word-wrap:break-word"> #include<stdio.h><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int crc32_table[256]; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int ulPolynomial = 0x04c11db7; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int Reflect(unsigned long int ref, char ch) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   {     unsigned long int value(0); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         // 交换bit0和bit7,bit1和bit6,类推 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         for(int i = 1; i < (ch + 1); i++) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          {            if(ref & 1) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                       value |= 1 << (ch - i); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                    ref >>= 1;      } <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         return value; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> } <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> init_crc32_table() <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   {     unsigned long int crc,temp; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         // 256个值 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         for(int i = 0; i <= 0xFF; i++) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          {   temp=Reflect(i, 8); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                crc32_table[i]= temp<< 24; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 for (int j = 0; j < 8; j++){ <br style="word-wrap:break-word"> <br style="word-wrap:break-word">              unsigned long int t1,t2; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   unsigned long int flag=crc32_table[i]&0x80000000; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 t1=(crc32_table[i] << 1); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 if(flag==0) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                   t2=0; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 else <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                   t2=ulPolynomial; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 crc32_table[i] =t1^t2 ;        } <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                crc=crc32_table[i]; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                crc32_table[i] = Reflect(crc32_table[i], 32); <br style="word-wrap:break-word">         }<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> unsigned long GenerateCRC32(char xdata * DataBuf,unsigned long  len) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   { <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         unsigned long oldcrc32; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         unsigned long crc32; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         unsigned long oldcrc; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         unsigned  int charcnt; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          char c,t; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         oldcrc32 = 0x00000000; //初值为0 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">      charcnt=0; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          while (len--) { <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                  t= (oldcrc32 >> 24) & 0xFF;   //要移出的字节的值 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">      oldcrc=crc_32_tab[t];         //根据移出的字节的值查表 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                  c=DataBuf[charcnt];          //新移进来的字节值 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                  oldcrc32= (oldcrc32 << 8) | c;   //将新移进来的字节值添在寄存器末字节中 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                  oldcrc32=oldcrc32^oldcrc;     //将寄存器与查出的值进行xor运算 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                  charcnt++; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         } <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          crc32=oldcrc32; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          return crc32; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> } <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 参数表可以先在PC机上算出来,也可在程序初始化时完成。下面是用于计算参数表的c语言子程序,在Visual C++ 6.0下编译通过。 <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #include <stdio.h> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int crc32_table[256]; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int ulPolynomial = 0x04c11db7; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int Reflect(unsigned long int ref, char ch) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   {     unsigned long int value(0); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         // 交换bit0和bit7,bit1和bit6,类推 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         for(int i = 1; i < (ch + 1); i++) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          {            if(ref & 1) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                       value |= 1 << (ch - i); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                    ref >>= 1;      } <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         return value; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> int main()<br style="word-wrap:break-word"> {<br style="word-wrap:break-word">      unsigned long int crc,temp; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         // 256个值 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         for(int i = 0; i <= 0xFF; i++) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          {<br style="word-wrap:break-word"> temp=Reflect(i, 8);<br style="word-wrap:break-word">                crc32_table[i]= temp<< 24; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 for (int j = 0; j < 8; j++){ <br style="word-wrap:break-word"> <br style="word-wrap:break-word">              unsigned long int t1,t2; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   unsigned long int flag=crc32_table[i]&0x80000000;<br style="word-wrap:break-word">                 t1=(crc32_table[i] << 1); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 if(flag==0) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                   t2=0; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 else <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                   t2=ulPolynomial; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 crc32_table[i] =t1^t2 ;       <br style="word-wrap:break-word"> } <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                crc=crc32_table[i];<br style="word-wrap:break-word">                crc32_table[i] = Reflect(crc32_table[i], 32);<br style="word-wrap:break-word">         }<br style="word-wrap:break-word"> return 0;<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> EOF<br style="word-wrap:break-word"> gcc -o crc crc.c<br style="word-wrap:break-word"> if [ $? -eq 0 ]; then<br style="word-wrap:break-word"> ./combine<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> echo 'Compile ERROR'<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 60.判断是否为空文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 61.终止程序<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> kill -KILL pidof %%1 -s<br style="word-wrap:break-word"> #killall %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 62.定时关机<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> shutdown -h %%1 & #23:00<br style="word-wrap:break-word"> #shutdown -h now<br style="word-wrap:break-word"> #halt<br style="word-wrap:break-word"> #/sbin/poweroff<br style="word-wrap:break-word"> #init 0<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 63.显示进程列表<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> ps aux<br style="word-wrap:break-word"> #fuser -l<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 64.遍历文件夹列出文件大小<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> du -sH "%%1/*"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 65.GOST算法<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 66.对目标压缩文件解压缩到指定文件夹<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 67.保存文件时重名自动生成新文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 68.打开网页<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> lynx %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 69.删除空文件夹整合操作<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 70.获取磁盘所有分区<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> df -k<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 71.激活一个程序或程序关联的文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 72.MP3播放<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> amp "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 73.WAV播放<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> amp "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 74.写图像到剪切板<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 75.从剪贴板复制图像到窗体<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 76.删除文件夹下的所有文件且不删除文件夹下的文件夹<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> rm -if "%%1/*"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 77.XML遍历结点属性值<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 78.Unicode文件转GB2312格式<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> iconv -f ucs2 -t  gbk %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 79.开源程序库Xercesc-C++代码工程中内联80.提取包含头文件列表<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 81.GB2312文件转Unicode格式<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> iconv -f gbk -t  ucs2 %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 82.Java程序打包<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 83.UTF-8文件转Unicode格式<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> iconv -f utf8 -t  ucs2 %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 84.创建PDF文档<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 85.创建Word文档<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 86.快速高效的文件加密<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 87.从CSV文件构造XML文档<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 88.从XML文档生成CSV文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 89.模拟键盘输入字符串<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 90.提取PDF文件中的文本<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 91.操作内存映射文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> 91.1发送内存映射数据<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 91.2接收内存映射数据<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 92.重定向windows控制台程序的输出信息<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 93.基数转序数<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 94.数字月份转英文<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 95.报表相关<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 96.根据进程名获取进程ID<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> pidof %%1 -s<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 96.BCP导入<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 97.BCP导出<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 98.计算文件MD5值<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> md5sum "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 99.计算获取文件夹中文件的MD5值<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 100.复制一个目录下所有文件到一个文件夹中<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> cp $(find "%%1" -name *.*) "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 101.移动一个目录下所有文件到一个文件夹中<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> mv $(find "%%1" -name *.*) "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 102.文件RSA高级加密<br style="word-wrap:break-word"> 十进制到十六进制<br style="word-wrap:break-word"> typeset -i16 BASE_16_NUM<br style="word-wrap:break-word"> BASE_16_NUM=%%1<br style="word-wrap:break-word"> echo $BASE_16_NUM<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 八进制到十六进制<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> typeset -i16 BASE_16_NUM<br style="word-wrap:break-word"> BASE_16_NUM=8#%%1<br style="word-wrap:break-word"> echo $BASE_16_NUM<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 十进制到八进制<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> printf %o %%1; echo<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 十进制到十六进制<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> printf %x %%1; echo<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 103.计算文件大小<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> wc "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 104.计算文件夹的大小<br style="word-wrap:break-word"> #!/sbin/ksh<br style="word-wrap:break-word"> dir=%%1<br style="word-wrap:break-word"> (cd $dir;pwd)<br style="word-wrap:break-word"> find $dir -type d -print | du | awk '{print $2, "== ("$1/2"kb)"}' |sort -f |<br style="word-wrap:break-word"> sed -e "s,[^ /]*/([^ /]*) ==,|--1," -e"s,[^ /]*/,| ,g"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 105.快速获得当前程序的驱动器、路径、文件名和扩展名<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 106.磁盘剩余空间计算<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> df -k<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 107.获取当前程序进程ID<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> pidof %%1 -s<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 108.全盘搜索文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> #updatedb<br style="word-wrap:break-word"> #locate %%1<br style="word-wrap:break-word"> slocate %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 109.获得当前登录的用户名<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> whoami<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 110.获得所有用户名<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> who<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 111.创建MySQL管理用户<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> mysqladmin -u root password %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 112.管理MySQL数据库服务器<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> 112.1.启动MySQL数据库服务器<br style="word-wrap:break-word"> mysqld -console<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 112.2.登录MySQL数据库服务器<br style="word-wrap:break-word"> 112.2.1.登录本地MySQL数据库服务器<br style="word-wrap:break-word"> mysql -uroot -p%%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 112.2.2.登录远程MySQL数据库服务器<br style="word-wrap:break-word"> mysql -h %%1 -u %%2 -p%%3<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 112.3.关闭MySQL数据库服务器<br style="word-wrap:break-word"> mysqladmin -u root shutdown<br style="word-wrap:break-word"> #pkill -9 mysql<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 112.4.测试MySQL数据库服务器<br style="word-wrap:break-word"> mysqlshow || mysqlshow -u root mysql || mysqladmin version status || mysql test<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 113.MySQL执行查询<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> mysqladmin -u %%1 -p%%2 SELECT * INTO OUTFILE './bestlovesky.xls' FROM bestlovesky WHERE 1 ORDER BY id DESC  LIMIT 0, 50;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> mysql -u %%1 -p%%2 -e "SELECT * INTO OUTFILE './bestlovesky.xls' FROM bestlovesky WHERE 1 ORDER BY id DESC  LIMIT 0, 50;"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 114.创建Oracle管理用户<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> 114.1.创建新用户<br style="word-wrap:break-word"> create user test identified by test default tablespace ts_test temporary<br style="word-wrap:break-word"> tablespace temp;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 114.2.给用户角色特权<br style="word-wrap:break-word"> grant connect,resource to test;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 115.登录Oracle数据库<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> sqlplusw<br style="word-wrap:break-word"> sqlplus /nolog<br style="word-wrap:break-word"> conn username/password@Oranet<br style="word-wrap:break-word"> conn system/systempwd@whfc<br style="word-wrap:break-word"> conn sys/syspwd@whfc as sysdba<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 115.创建Oracle表空间<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> conn system@whfc01<br style="word-wrap:break-word"> create tablespace ts_test datafile '/data2/oradata/ciis/ts_test01.dbf' size<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 116.添加Oracle数据文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> alter tablespace ts_test add datafile '/data2/oradata/ciis/ts_test02.dbf' size<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 117.查看Oracle表空间大小<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> desc DBA_DATA_FILES<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 118.查看Oracle剩余表空间大小<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> desc DBA_FREE_SPACE<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 119.查看Oracle当前用户表名<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> select * from tab;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 120.Oracle创建索引<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> CREATE INDEX idx_book_bookid ON book(bookname);<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 121.Oracle创建主键约束<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> ALTER TABLE book ADD CONSTRAINT pk_book_bookid PRIMARY KEY (bookid);<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 122.Oracle显示表结构<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> desc book<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 123.Oracle查看表的索引<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> column index_name format a30<br style="word-wrap:break-word"> select table_name, index_name from user_indexes;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 124.Oracle查看索引列<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> select table_name, index_name, column_name, column_position from user_ind_columns;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 125.Oracle查看数据段占空间大小<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> desc user_segments<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 126.Oracle查看表占空间大小<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> select segment_name,segment_type,bytes from user_segments where segment_type='TABLE';<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 127.安全删除USB<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rundll32.exe shell32.dll,Control_RunDLL hotplug.dll<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 128.打开SQL Server Management Studio<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> sqlwb %%1.sql<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 129.MySQL数据库导出备份<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> mysqldump -u %%1 -p %%2 %%3>%%4.sql<br style="word-wrap:break-word"> mysqldump --opt test > mysql.test //将数据库test导出到mysql.test文件,后面是一个文本文件<br style="word-wrap:break-word"> mysqldump -u root -p123456 --databases dbname > mysql.dbname //就是把数据库dbname导出到文件mysql.dbname中。<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 130.MySQL数据库数据导入<br style="word-wrap:break-word"> mysql -u %%1 -p %%2 %%3<%%4.sql<br style="word-wrap:break-word"> mysqlimport -u root -p123456 < mysql.dbname<br style="word-wrap:break-word"> 将文本数据导入数据库:<br style="word-wrap:break-word"> 文本数据的字段之间用tab键隔开<br style="word-wrap:break-word"> use test<br style="word-wrap:break-word"> load data local infile "文件名" into table 表名;<br style="word-wrap:break-word"> eg: load data local infile "D:/mysql.txt" into table mytable;<br style="word-wrap:break-word"> 导入.sql 文件命令<br style="word-wrap:break-word"> use database<br style="word-wrap:break-word"> source d:/mysql.sql;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 131.MySQL数据库检查<br style="word-wrap:break-word"> mysqlcheck -o %%3 -u %%1 -p %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 132.MySQL数据表文件修复<br style="word-wrap:break-word"> myisamchk -B -o %%1.myd<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 1,查看数据库状态 及启动停止<br style="word-wrap:break-word"> /etc/init.d/mysqld status<br style="word-wrap:break-word"> /etc/init.d/mysqld start<br style="word-wrap:break-word"> /etc/init.d/mysqld stop<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 2,给用户配置初始密码123456:<br style="word-wrap:break-word"> mysqladmin -u root -password 123456<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 3,修改root用户密码为 abc123<br style="word-wrap:break-word"> mysqladmin -u root -p123456 password abc123<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 4,如果想去掉密码:<br style="word-wrap:break-word"> mysqladmin -u root -pabc123 password ""<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 5,root连接数据库有密码和无密码:<br style="word-wrap:break-word"> mysql -u root(-uroot) -p<br style="word-wrap:break-word"> mysql<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 6,增加用户 test1 密码 abc,让它可以在任何主机上登录,并对所有数据库有查询,插入,修改,删除的权限:<br style="word-wrap:break-word"> 格式: grant select on 数据库.* to 用户名@登录主机 identified by "密码"<br style="word-wrap:break-word"> grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 8,增加一个用户test2,让它只可以在localhost上登录,并可以对数据库mydb进行查询,插入,修改,删除的操作,<br style="word-wrap:break-word"> 这样用户即使使用知道test2的密码,他也无法从internet 上直接访问数据库,只能通过mysql主机上的web页面来访问。<br style="word-wrap:break-word"> grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";<br style="word-wrap:break-word"> grant select,insert,update,delete on mydb.* to test2@localhost identified by ""; 设置无密码<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 9,显示数据库列表:<br style="word-wrap:break-word"> show databases;<br style="word-wrap:break-word"> use mysql 打开库<br style="word-wrap:break-word"> show tables;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 10,表的操作<br style="word-wrap:break-word"> describle 表名; 显示数据表的结构<br style="word-wrap:break-word"> create database 库名;<br style="word-wrap:break-word"> drop database 库名;<br style="word-wrap:break-word"> create table 表名(字段设定列表)<br style="word-wrap:break-word"> drop table 表名;<br style="word-wrap:break-word"> delete from 表名;清空表记录<br style="word-wrap:break-word"> select * from 表名; 显示表中的记录<br style="word-wrap:break-word"> insert into 表名 values(, ,)<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> alter table 表名 add column <字段名><字段选项><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 133.检查端口占用<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> netstat -ano<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 134.Linux下检查Apache是否安装<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rpm -qa | grep httpd<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 135.Linux下启动Apache服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service httpd start<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 136.Linux下停止Apache服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service httpd stop<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 137.Linux下重新启动Apache服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service httpd restart<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 138.Linux下自动加载Apache 服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> chkconfig - level 3 httpd on<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 139.Linux下不自动加载Apache 服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> chkconfig - level 3 httpd off<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 140.Linux下检查VSFTP是否安装<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rpm -qa | grep vsftpd<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 141.Linux下启动VSFTP服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service vsftpd start<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 142.Linux下停止VSFTP服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service vsftpd stop<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 143.Linux下重新启动VSFTP服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service vsftpd restart<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 144.Linux下检查VSFTP是否被启动<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> pstree | grep vsftpd<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 145.Linux下检查Sendmail是否安装<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rpm -qa | grep sendmail<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 146.Linux下启动Sendmail服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service sendmail start<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 147.Linux下停止Sendmail服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service sendma stop<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 148.Linux下重新启动Sendmail服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service sendmail restart<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 149.Linux下自动加载Sendmail 服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> chkconfig - level 3 sendmail on<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 150.Linux下不自动加载Sendmail 服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> chkconfig - level 3 sendmail off<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 151.Linux下文本图形界面配置启动服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> ntsysv<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 152.以数组的方式删除文件夹<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 153.GCC批量编译<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find -type f \( -iname '*.c' -o -iname '*.cpp' \) -print |<br style="word-wrap:break-word"> while read filename<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     case "$filename" in<br style="word-wrap:break-word">     *.c)<br style="word-wrap:break-word">       gcc "$filename" -o "$(dirname "$filename")"/"$(basename "$filename" .c)"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.cpp)<br style="word-wrap:break-word">         gcc "$filename" -o "$(dirname "$filename")"/"$(basename "$filename" .cpp)"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     esac<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 154.批量赋予可执行权限<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find "$PWD" -type f \( -iname '*.sh' -o  -iname '*.csh' -o  -iname '*.ksh' -o -iname '*.pl' -o -iname '*.bin' -o -iname '*.run' -o -iname '*.bundle' -o -iname '*.rb' -o -iname '*.py' \) -print0 | xargs -0 chmod +x<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> for file in *.sh *.pl *.bin *.run *.bundle *.rb *.py<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [[ ! "$file" =~ \*.[A-Za-z]+ ]]; then<br style="word-wrap:break-word"> chmod +x "$(file)"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $(pwd) -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> for file in $path/*.sh $path/*.pl $path/*.bin $path/*.run $path/*.bundle $path/*.rb $path/*.py<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [[ ! "$file" =~ \*.[A-Za-z]+ ]]; then<br style="word-wrap:break-word"> chmod +x "$(path)/$(file)"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 155.批量执行<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find -type f \( -iname '*.sh' -o  -iname '*.csh' -o  -iname '*.ksh' -o -iname '*.pl' -o -iname '*.bin' -o -iname '*.run' -o -iname '*.bundle' -o -iname '*.bin' -o -iname '*.class' -o -iname '*.rpm' -o -iname '*.rb' -o -iname '*.py' -o -iname '*.jar' \) -print |<br style="word-wrap:break-word"> while read filename<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     case "$filename" in<br style="word-wrap:break-word">     *.sh | *.csh | *.ksh)<br style="word-wrap:break-word"> if [ ! "./""$(basename $filename)" = $0 ]; then<br style="word-wrap:break-word">         xterm -e "$filename"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.pl)<br style="word-wrap:break-word">         xterm -e perl "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.bin | *.run | *.bundle)<br style="word-wrap:break-word">         xterm -e "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.class)<br style="word-wrap:break-word">         xterm -e java "$(dirname "$filename")"/"$(basename "$filename" .class)"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.rpm)<br style="word-wrap:break-word">         xterm -e rpm -ivh "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.rb)<br style="word-wrap:break-word">         xterm -e ruby "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.py)<br style="word-wrap:break-word">         xterm -e python "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.jar)<br style="word-wrap:break-word">         xterm -e java -jar "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     esac<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find -maxdepth 1 -type f \( -iname '*.sh' -o -iname '*.pl' -o -iname '*.bin' -o -iname '*.run' -o -iname '*.bundle' -o -iname '*.bin' -o -iname '*.class' -o -iname '*.rpm' -o -iname '*.rb' -o -iname '*.py' -o -iname '*.jar' \) -print<br style="word-wrap:break-word"> while read file<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     case "${file##*.}" in<br style="word-wrap:break-word">         sh ) xterm -e """"$file"""";;<br style="word-wrap:break-word">         pl ) xterm -e perl """"$file"""";;<br style="word-wrap:break-word">         bin ) xterm -e """"$file"""";;<br style="word-wrap:break-word">         run ) xterm -e """"$file"""";;<br style="word-wrap:break-word">         bundle ) xterm -e """"$file"""";;<br style="word-wrap:break-word">         class ) xterm -e java """"${file%.*}"""";;<br style="word-wrap:break-word">         rpm ) xterm -e rpm -ivh """"$file"""";;<br style="word-wrap:break-word">         rb ) xterm -e ruby """"$file"""";;<br style="word-wrap:break-word">         py ) xterm -e python """"$file"""";;<br style="word-wrap:break-word">         jar ) xterm -e java -jar """"$file"""";;<br style="word-wrap:break-word">     esac<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 156.获取操作系统版本<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> uname -r<br style="word-wrap:break-word"> #uname -a<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 157.自身复制<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> cp $0 "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 158.GCC批量创建静态库<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find -type f \( -iname '*.c' -o -iname '*.cpp' \) -print |<br style="word-wrap:break-word"> while read filename<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     case "$filename" in<br style="word-wrap:break-word">     *.c)<br style="word-wrap:break-word">       g++  -c -o "$(dirname "$filename")"/"$(basename "$filename" .c)".o"" "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.cpp)<br style="word-wrap:break-word">       g++  -c -o "$(dirname "$filename")"/"$(basename "$filename" .cpp)".o"" "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     esac<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $(pwd) -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> ar ru $path".a" $path"/*.o" && ranlib $path".a"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> find "$PWD" -type f \( -iname '*.o' \) -print0 | xargs -0 rm -if<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 159.Java批量打包EJB<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find "$PWD" -type f \( -iname '*.java' \) -print0 | xargs -0 javac<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $(pwd) -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> jar -cvf "$(path".jar")" "$(path"/*.*")" && cp "$(path".jar")" "$(JBOSS_HOME"/server/default/deploy")"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> find "$PWD" -type f \( -iname '*.class' \) -print0 | xargs -0 rm -if<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 160.获取环境变量<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 161.dd<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> dd<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 162.显示只有小写字母的文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> ls -1|awk '/^[[:lower:]].*/'<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 163.Zip压缩目录中的所有文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> targetpath="%%2"<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $direc -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> mkdir -p "$targetpath/${path:${#direc}+1}"<br style="word-wrap:break-word"> for file in $path/*<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [ -f $file ]; then<br style="word-wrap:break-word"> zip -j "$targetpath/${path:${#direc}+1}/${file:${#path}+1}.zip" "$file"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 164.Zip解压缩目录中的所有文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> targetpath="%%2"<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $direc -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> mkdir -p "$targetpath/${path:${#direc}+1}"<br style="word-wrap:break-word"> unzip -x "$path/*.zip" -d "$targetpath/${path:${#direc}+1}"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 165.分布式复制文件夹<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> targetpath="%%2"<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $direc -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> mkdir -p "$targetpath/${path:${#direc}+1}"<br style="word-wrap:break-word"> rm -if "$targetpath/${path:${#direc}+1}/*.tmp"<br style="word-wrap:break-word"> for file in $path/*<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [ -f $file ]; then<br style="word-wrap:break-word"> cp "$file" "$targetpath/${path:${#direc}+1}/${file:${#path}+1}.tmp"<br style="word-wrap:break-word"> mv "$targetpath/${path:${#direc}+1}/${file:${#path}+1}.tmp" "$targetpath/${path:${#direc}+1}/${file:${#path}+1}"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 166.注册反注册组件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> regsvr32 "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 167.LZMA<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 168.CAB压缩文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 169.CAB解压缩文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 170.锁定屏幕<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> RUNDLL32.exe USER32,LockWorkStation<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 171.以其它用户的身份运行程序<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 172.添加系统用户<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> useradd "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 173.删除系统用户<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> userdel "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 174.添加用户组<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> groupadd -g 2000 "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 175.删除用户组<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> groupdel "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 176.赋予管理员权限<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 177.收回管理员权限<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 178.遍历目录产生删除文件的脚本<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 179.LZW压缩文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> z<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 180.LZW解压缩文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> z<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 181.递归赋予目录权限<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $direc -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> chown -R root.root "$path"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 182.卸载RPM包<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> rpm -e  "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 183.删除源文件中的注释<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 184.设置目录下所有文件属性为可写<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 185.统计目录下所有文件的总共行数<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> cat * |wc<br style="word-wrap:break-word"> ls *|xargs wc -l<br style="word-wrap:break-word"> find ./ -name "*c" | xargs wc -l<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 186.删除自身<br style="word-wrap:break-word"> #!/bin/rm<br style="word-wrap:break-word"> exit 65<br style="word-wrap:break-word"> #rm $0<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 187.打开终端<br style="word-wrap:break-word"> #!/bin/bash -l<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 188.弹出光驱<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> eject<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 189.收回光驱<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> eject -t<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 190.磁盘总空间计算<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 191.解析CSV文件<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 192.按行保存文件为数组<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 193.MySQL执行SQL文件<br style="word-wrap:break-word"> mysqladmin -u %%1 -p%%2 < %%3.sql<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> mysql -u %%1 -p%%2 -e "SOURCE %%3.sql"</span> </div> </div> <div class="Blog_con2_1 Blog_con3_2" style="word-wrap:break-word; margin-top:50px; position:relative; line-height:22px"> <div style="word-wrap:break-word; height:30px"> <div class="bdsharebuttonbox bdshare-button-style0-16" style="word-wrap:break-word; zoom:1; height:30px"> </div> </div> </div> <div class="Blog_wz1" style="word-wrap:break-word; font-size:16px"> <div style="word-wrap:break-word"> <span style="word-wrap:break-word; border-collapse:separate; font-family:Tahoma; border-spacing:0px; font-size:14px">1.创建文件夹<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> mkdir -m 777 "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 2.创建文件<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> touch "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 3.删除文件<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> rm -if "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 4.删除文件夹<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> rm -rf "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 5.删除一个目录下所有的文件夹<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> for dir2del in $direc/* ; do<br style="word-wrap:break-word"> if [ -d $dir2del ]; then<br style="word-wrap:break-word">   rm -rf $dir2del<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 6.清空文件夹<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> rm -if $direc/*<br style="word-wrap:break-word"> for dir2del in $direc/* ; do<br style="word-wrap:break-word"> if [ -d $dir2del ]; then<br style="word-wrap:break-word">   rm -rf $dir2del<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 7.读取文件<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> 7.1.操作系统默认编码<br style="word-wrap:break-word"> cat "%%1" | while read line; do<br style="word-wrap:break-word"> echo $line;<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 7.2.UTF-8编码<br style="word-wrap:break-word"> cat "%%1" | while read line; do<br style="word-wrap:break-word"> echo $line;<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 7.3.分块读取<br style="word-wrap:break-word"> cat "%%1" | while read line; do<br style="word-wrap:break-word"> echo $line;<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 8.写入文件<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> cat > "%%1" << EOF<br style="word-wrap:break-word"> %%2<br style="word-wrap:break-word"> EOF<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> tee "%%1" > /dev/null << EOF<br style="word-wrap:break-word"> %%2<br style="word-wrap:break-word"> EOF<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #sed -i '$a %%2' %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 9.写入随机文件<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> cat > "%%1" << EOF<br style="word-wrap:break-word"> %%2<br style="word-wrap:break-word"> EOF<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> tee "%%1" > /dev/null << EOF<br style="word-wrap:break-word"> %%2<br style="word-wrap:break-word"> EOF<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #sed -i '$a %%2' %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 10.读取文件属性<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> file=%%1<br style="word-wrap:break-word"> file=${file:?'必须给出参数'}<br style="word-wrap:break-word"> if [ ! -e $file ]; then<br style="word-wrap:break-word">     echo "$file 不存在"<br style="word-wrap:break-word">     exit 1<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ -d $file ]; then<br style="word-wrap:break-word">     echo "$file 是一个目录"<br style="word-wrap:break-word">     if [ -x $file ]; then<br style="word-wrap:break-word">         echo "可以"<br style="word-wrap:break-word">     else<br style="word-wrap:break-word">         echo "不可以"<br style="word-wrap:break-word">     fi<br style="word-wrap:break-word">     echo "对此进行搜索"  <br style="word-wrap:break-word"> elif [ -f $file ]; then<br style="word-wrap:break-word">     echo "$file 是一个正规文件"<br style="word-wrap:break-word"> else<br style="word-wrap:break-word">     echo "$file不是一个正规文件"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ -O $file ]; then<br style="word-wrap:break-word">     echo "你是$file的拥有者"<br style="word-wrap:break-word"> else<br style="word-wrap:break-word">     echo "你不是$file的拥有者"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ -r $file ]; then<br style="word-wrap:break-word">     echo "你对$file拥有"<br style="word-wrap:break-word"> else<br style="word-wrap:break-word">     echo "你并不对$file拥有"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> echo "可读权限"<br style="word-wrap:break-word"> if [ -w $file ]; then<br style="word-wrap:break-word">     echo "你对$file拥有"<br style="word-wrap:break-word"> else<br style="word-wrap:break-word">     echo "你并不对$file拥有"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> echo "可写权限"<br style="word-wrap:break-word"> if [ -x $file -a ! -d $file ]; then<br style="word-wrap:break-word">     echo "你拥有对$file"<br style="word-wrap:break-word"> else<br style="word-wrap:break-word">     echo "你并不拥有对$file"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> echo "可执行的权限"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 11.写入文件属性<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> #修改存放在ext2、ext3、ext4、xfs、ubifs、reiserfs、jfs等文件系统上的文件或目录属性,使用权限超级用户。<br style="word-wrap:break-word"> #一些功能是由Linux内核版本来支持的,如果Linux内核版本低于2.2,那么许多功能不能实现。同样-D检查压缩文件中的错误的功能,需要2.5.19以上内核才能支持。另外,通过chattr命令修改属性能够提高系统的安全性,但是它并不适合所有的目录。chattr命令不能保护/、/dev、/tmp、/var目录。<br style="word-wrap:break-word"> chattr [-RV] [-+=AacDdijsSu] [-v version] 文件或目录<br style="word-wrap:break-word">   -R:递归处理所有的文件及子目录。<br style="word-wrap:break-word">   -V:详细显示修改内容,并打印输出。<br style="word-wrap:break-word">   -:失效属性。<br style="word-wrap:break-word">   +:激活属性。<br style="word-wrap:break-word">   = :指定属性。<br style="word-wrap:break-word">   A:Atime,告诉系统不要修改对这个文件的最后访问时间。<br style="word-wrap:break-word">   S:Sync,一旦应用程序对这个文件执行了写操作,使系统立刻把修改的结果写到磁盘。<br style="word-wrap:break-word">   a:Append Only,系统只允许在这个文件之后追加数据,不允许任何进程覆盖或截断这个文件。如果目录具有这个属性,系统将只允许在这个目录下建立和修改文件,而不允许删除任何文件。<br style="word-wrap:break-word">   i:Immutable,系统不允许对这个文件进行任何的修改。如果目录具有这个属性,那么任何的进程只能修改目录之下的文件,不允许建立和删除文件。<br style="word-wrap:break-word">   D:检查压缩文件中的错误。<br style="word-wrap:break-word">   d:No dump,在进行文件系统备份时,dump程序将忽略这个文件。<br style="word-wrap:break-word">   C:Compress,系统以透明的方式压缩这个文件。从这个文件读取时,返回的是解压之后的数据;而向这个文件中写入数据时,数据首先被压缩之后才写入磁盘。<br style="word-wrap:break-word">   S:Secure Delete,让系统在删除这个文件时,使用0填充文件所在的区域。<br style="word-wrap:break-word">   u:Undelete,当一个应用程序请求删除这个文件,系统会保留其数据块以便以后能够恢复删除这个文件。<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 12.枚举一个目录中的所有文件夹<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find "%%1" -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> #"$path"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 13.复制文件夹<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> cp -rf "%%1" "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 14.复制一个目录下所有的文件夹到另一个目录下<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> for dir2cp in $direc/* ; do<br style="word-wrap:break-word"> if [ -d $dir2cp ]; then<br style="word-wrap:break-word">   cp $dir2cp "%%2"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 15.移动文件夹<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> mv -rf "%%1" "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 16.移动一个目录下所有的文件夹到另一个目录下<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> for dir2mv in $direc/* ; do<br style="word-wrap:break-word"> if [ -d $dir2mv ]; then<br style="word-wrap:break-word">   mv $dir2mv "%%2"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 17.以一个文件夹的框架在另一个目录下创建文件夹和空文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $direc -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> mkdir -p "%%2/${path:${#direc}+1}"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> #cp -a "%%1" "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 表达式 含义<br style="word-wrap:break-word"> ${#string}<br style="word-wrap:break-word"> {#string}<br style="word-wrap:break-word"> 1,取得字符串长度<br style="word-wrap:break-word"> string=abc12342341          //等号二边不要有空格<br style="word-wrap:break-word"> echo ${#string}             //结果11<br style="word-wrap:break-word"> expr length $string         //结果11<br style="word-wrap:break-word"> expr "$string" : ".*"       //结果11 分号二边要有空格,这里的:根match的用法差不多2,字符串所在位置<br style="word-wrap:break-word"> expr index $string '123'    //结果4 字符串对应的下标是从0开始的这个方法让我想起来了js的indexOf,各种语言对字符串的操作方法大方向都差不多,如果有语言基础的话,学习shell会很快的。<br style="word-wrap:break-word"> 3,从字符串开头到子串的最大长度<br style="word-wrap:break-word"> expr match $string 'abc.*3' //结果9个人觉得这个函数的用处不大,为什么要从开头开始呢。<br style="word-wrap:break-word"> 4,字符串截取<br style="word-wrap:break-word"> echo ${string:4}      //2342341  从第4位开始截取后面所有字符串<br style="word-wrap:break-word"> echo ${string:3:3}    //123      从第3位开始截取后面3位<br style="word-wrap:break-word"> echo ${string:3:6}    //123423   从第3位开始截取后面6位<br style="word-wrap:break-word"> echo ${string: -4}    //2341  :右边有空格   截取后4位<br style="word-wrap:break-word"> echo ${string:(-4)}   //2341  同上<br style="word-wrap:break-word"> expr substr $string 3 3   //123  从第3位开始截取后面3位上面的方法让我想起了,php的substr函数,后面截取的规则是一样的。<br style="word-wrap:break-word"> 5,匹配显示内容<br style="word-wrap:break-word"> //例3中也有match和这里的match不同,上面显示的是匹配字符的长度,而下面的是匹配的内容<br style="word-wrap:break-word"> expr match $string '\([a-c]*[0-9]*\)'  //abc12342341<br style="word-wrap:break-word"> expr $string : '\([a-c]*[0-9]\)'       //abc1<br style="word-wrap:break-word"> expr $string : '.*\([0-9][0-9][0-9]\)' //341 显示括号中匹配的内容这里括号的用法,是不是根其他的括号用法有相似之处呢,<br style="word-wrap:break-word"> 6,截取不匹配的内容<br style="word-wrap:break-word"> echo ${string#a*3}     //42341  从$string左边开始,去掉最短匹配子串<br style="word-wrap:break-word"> echo ${string#c*3}     //abc12342341  这样什么也没有匹配到<br style="word-wrap:break-word"> echo ${string#*c1*3}   //42341  从$string左边开始,去掉最短匹配子串<br style="word-wrap:break-word"> echo ${string##a*3}    //41     从$string左边开始,去掉最长匹配子串<br style="word-wrap:break-word"> echo ${string%3*1}     //abc12342  从$string右边开始,去掉最短匹配子串<br style="word-wrap:break-word"> echo ${string%%3*1}    //abc12     从$string右边开始,去掉最长匹配子串这里要注意,必须从字符串的第一个字符开始,或者从最后一个开始,<br style="word-wrap:break-word"> 7,匹配并且替换<br style="word-wrap:break-word"> echo ${string/23/bb}   //abc1bb42341  替换一次<br style="word-wrap:break-word"> echo ${string//23/bb}  //abc1bb4bb41  双斜杠替换所有匹配<br style="word-wrap:break-word"> echo ${string/#abc/bb} //bb12342341   #以什么开头来匹配,根php中的^有点像<br style="word-wrap:break-word"> echo ${string/%41/bb}  //abc123423bb  %以什么结尾来匹配,根php中的$有点像<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc=$(pwd)<br style="word-wrap:break-word"> for file in "$(direc)/*"<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [ "${file##*.}" = "sh" ]; then<br style="word-wrap:break-word"> xterm -e bash $file<br style="word-wrap:break-word"> elif [ "${file##*.}" = "bin" ]; then<br style="word-wrap:break-word"> xterm -e $file<br style="word-wrap:break-word"> elif [ "${file##*.}" = "run" ]; then<br style="word-wrap:break-word"> xterm -e $file<br style="word-wrap:break-word"> elif [ "${file##*.}" = "bundle" ]; then<br style="word-wrap:break-word"> xterm -e $file<br style="word-wrap:break-word"> elif [ "${file##*.}" = "pl" ]; then<br style="word-wrap:break-word"> xterm -e perl $file<br style="word-wrap:break-word"> elif [ "${file##*.}" = "class" ]; then<br style="word-wrap:break-word"> xterm -e java ${file%.*}<br style="word-wrap:break-word"> elif [ "${file##*.}" = "rpm" ]; then<br style="word-wrap:break-word"> xterm -e rpm -ivh $file<br style="word-wrap:break-word"> elif [ "${file##*.}" = "rb" ]; then<br style="word-wrap:break-word"> xterm -e ruby $file<br style="word-wrap:break-word"> elif [ "${file##*.}" = "py" ]; then<br style="word-wrap:break-word"> xterm -e python $file<br style="word-wrap:break-word"> elif [ "${file##*.}" = "jar" ]; then<br style="word-wrap:break-word"> xterm -e java -jar $file<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $direc -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> for file in `ls $path`<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [ "${file##*.}" = "sh" ]; then<br style="word-wrap:break-word"> xterm -e bash """"$path"/"$file""""<br style="word-wrap:break-word"> elif [ "${file##*.}" = "bin" ]; then<br style="word-wrap:break-word"> xterm -e """"$path"/"$file""""<br style="word-wrap:break-word"> elif [ "${file##*.}" = "run" ]; then<br style="word-wrap:break-word"> xterm -e """"$path"/"$file""""<br style="word-wrap:break-word"> elif [ "${file##*.}" = "bundle" ]; then<br style="word-wrap:break-word"> xterm -e """"$path"/"$file""""<br style="word-wrap:break-word"> elif [ "${file##*.}" = "pl" ]; then<br style="word-wrap:break-word"> xterm -e perl """"$path"/"$file""""<br style="word-wrap:break-word"> elif [ "${file##*.}" = "class" ]; then<br style="word-wrap:break-word"> xterm -e java """"$path"/"${file%.*}""""<br style="word-wrap:break-word"> elif [ "${file##*.}" = "rpm" ]; then<br style="word-wrap:break-word"> xterm -e rpm -ivh """"$path"/"$file""""<br style="word-wrap:break-word"> elif [ "${file##*.}" = "rb" ]; then<br style="word-wrap:break-word"> xterm -e ruby """"$path"/"$file""""<br style="word-wrap:break-word"> elif [ "${file##*.}" = "py" ]; then<br style="word-wrap:break-word"> xterm -e python """"$path"/"$file""""<br style="word-wrap:break-word"> elif [ "${file##*.}" = "jar" ]; then<br style="word-wrap:break-word"> xterm -e java -jar """"$path"/"$file""""<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 18.复制文件<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> cp %%1 %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 19.复制一个目录下所有的文件到另一个目录<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" $(pwd)<br style="word-wrap:break-word"> for file in "$direc/*"<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> cp "$file" "%%1"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 20.提取扩展名<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> %%2=${%%1##.}<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 21.提取文件名<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> %%2="$(basename %%1)"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 22.提取文件路径<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> %%2="$(dirname %%1)"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 23.替换扩展名<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> %%3="$(basename %%1)$%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 24.追加路径<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> %%3="$(dirname %%1)/$%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 25.移动文件<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> mv "%%1" "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 26.移动一个目录下所有文件到另一个目录<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for file in "$(direc)/*"<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> mv "$file" "%%1"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 27.指定目录下搜索文件<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> find -name "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 28.打开文件对话框<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> %%1="$(Xdialog --fselect '~/' 0 0 2>&1)"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 29.文件分割<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> split -b 2k "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> while read f1 f2 f3<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     echo $f1 >> f1<br style="word-wrap:break-word">     echo $f2 >> f2<br style="word-wrap:break-word">     echo $f3 >> f3<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word">   linenum=`wc   -l   httperr8007.log|   awk   '{print   $1}'`  <br style="word-wrap:break-word">   n1=1  <br style="word-wrap:break-word">   file=1  <br style="word-wrap:break-word">   while   [   $n1   -lt   $linenum   ]  <br style="word-wrap:break-word">   do  <br style="word-wrap:break-word">                   n2=`expr   $n1   +   999`  <br style="word-wrap:break-word">                   sed   -n   "${n1},   ${n2}p"   httperr8007.log >   file_$file.log    <br style="word-wrap:break-word">                   n1=`expr   $n2   +   1`  <br style="word-wrap:break-word">                   file=`expr   $file   +   1`  <br style="word-wrap:break-word">   done  <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 其中httperr8007.log为你想分割的大文件,file_$file.log  为分割后的文件,最后为file_1.log,file_2.log,file_3.log……,分割完后的每个文件只有1000行(参数可以自己设置)<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> split 参数:<br style="word-wrap:break-word"> -b  :后面可接欲分割成的档案大小,可加单位,例如 b, k, m 等;<br style="word-wrap:break-word"> -l  :以行数来进行分割;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #按每个文件1000行来分割除<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> split -l 1000 httperr8007.log httperr<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> httpaa,httpab,httpac ........<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #按照每个文件100K来分割<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> split -b 100k httperr8007.log http<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> httpaa,httpab,httpac ........<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> if [ $# -ne 2 ]; then<br style="word-wrap:break-word"> echo 'Usage: split file size(in bytes)'<br style="word-wrap:break-word"> exit<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> file=$1<br style="word-wrap:break-word"> size=$2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> if [ ! -f $file ]; then<br style="word-wrap:break-word"> echo "$file doesn't exist"<br style="word-wrap:break-word"> exit<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #TODO: test if $size is a valid integer<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> filesize=`/bin/ls -l $file | awk '{print $5}'`<br style="word-wrap:break-word"> echo filesize: $filesize<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> let pieces=$filesize/$size<br style="word-wrap:break-word"> let remain=$filesize-$pieces*$size<br style="word-wrap:break-word"> if [ $remain -gt 0 ]; then<br style="word-wrap:break-word"> let pieces=$pieces+1<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> echo pieces: $pieces<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> i=0<br style="word-wrap:break-word"> while [ $i -lt $pieces ];<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> echo split: $file.$i:<br style="word-wrap:break-word"> dd if=$file of=$file.$i bs=$size count=1 skip=$i<br style="word-wrap:break-word"> let i=$i+1<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> echo "#!/bin/bash" > merge<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> echo "i=0" >> merge<br style="word-wrap:break-word"> echo "while [ $i -lt $pieces ];" >> merge<br style="word-wrap:break-word"> echo "do" >> merge<br style="word-wrap:break-word"> echo " echo merge: $file.$i" >> merge<br style="word-wrap:break-word"> echo " if [ ! -f $file.$i ]; then" >> merge<br style="word-wrap:break-word"> echo " echo merge: $file.$i missed" >> merge<br style="word-wrap:break-word"> echo " rm -f $file.merged" >> merge<br style="word-wrap:break-word"> echo " exit" >> merge<br style="word-wrap:break-word"> echo " fi" >> merge<br style="word-wrap:break-word"> echo " dd if=$file.$i of=$file.merged bs=$size count=1 seek=$i" >> merge<br style="word-wrap:break-word"> echo " let i=$i+1" >> merge<br style="word-wrap:break-word"> echo "done" >> merge<br style="word-wrap:break-word"> chmod u+x merge'<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 30.文件合并<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> cp "%%1"+"%%2" "%%3"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> exec 3<f1<br style="word-wrap:break-word"> exec 4<f2<br style="word-wrap:break-word"> while read f1 <&3 && read f2 <&4<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     echo $f1 $f2 >> join.txt<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> if [ $# -ne 2 ]; then<br style="word-wrap:break-word"> echo 'Usage: split file size(in bytes)'<br style="word-wrap:break-word"> exit<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> file=$1<br style="word-wrap:break-word"> size=$2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> if [ ! -f $file ]; then<br style="word-wrap:break-word"> echo "$file doesn't exist"<br style="word-wrap:break-word"> exit<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #TODO: test if $size is a valid integer<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> filesize=`/bin/ls -l $file | awk '{print $5}'`<br style="word-wrap:break-word"> echo filesize: $filesize<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> let pieces=$filesize/$size<br style="word-wrap:break-word"> let remain=$filesize-$pieces*$size<br style="word-wrap:break-word"> if [ $remain -gt 0 ]; then<br style="word-wrap:break-word"> let pieces=$pieces+1<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> echo pieces: $pieces<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> i=0<br style="word-wrap:break-word"> while [ $i -lt $pieces ];<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> echo split: $file.$i:<br style="word-wrap:break-word"> dd if=$file of=$file.$i bs=$size count=1 skip=$i<br style="word-wrap:break-word"> let i=$i+1<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> echo "#!/bin/bash" > merge<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> echo "i=0" >> merge<br style="word-wrap:break-word"> echo "while [ $i -lt $pieces ];" >> merge<br style="word-wrap:break-word"> echo "do" >> merge<br style="word-wrap:break-word"> echo " echo merge: $file.$i" >> merge<br style="word-wrap:break-word"> echo " if [ ! -f $file.$i ]; then" >> merge<br style="word-wrap:break-word"> echo " echo merge: $file.$i missed" >> merge<br style="word-wrap:break-word"> echo " rm -f $file.merged" >> merge<br style="word-wrap:break-word"> echo " exit" >> merge<br style="word-wrap:break-word"> echo " fi" >> merge<br style="word-wrap:break-word"> echo " dd if=$file.$i of=$file.merged bs=$size count=1 seek=$i" >> merge<br style="word-wrap:break-word"> echo " let i=$i+1" >> merge<br style="word-wrap:break-word"> echo "done" >> merge<br style="word-wrap:break-word"> chmod u+x merge'<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 31.文件简单加密<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> #make test && make strings && sudo make install<br style="word-wrap:break-word"> shc -r -f %%1.sh<br style="word-wrap:break-word"> #%%1.x<br style="word-wrap:break-word"> #%%1.x.c<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 32.文件简单解密<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> #make test && make strings && sudo make install<br style="word-wrap:break-word"> shc -r -f %%1.sh<br style="word-wrap:break-word"> #%%1.x<br style="word-wrap:break-word"> #%%1.x.c<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 33.读取ini文件属性<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> if [ "$%%3" = "" ];then<br style="word-wrap:break-word">    sed -n "/\[$%%2\]/,/\[.*\]/{<br style="word-wrap:break-word">    /^\[.*\]/d<br style="word-wrap:break-word">    /^[ ]*$/d<br style="word-wrap:break-word">    s/;.*$//<br style="word-wrap:break-word">    p<br style="word-wrap:break-word">    }" $1<br style="word-wrap:break-word"> elif [ "$%%4" = "" ];then<br style="word-wrap:break-word">    sed -n "/\[$%%2\]/,/\[.*\]/{<br style="word-wrap:break-word">    /^\[.*\]/d<br style="word-wrap:break-word">    /^[ ]*$/d<br style="word-wrap:break-word">    s/;.*$//<br style="word-wrap:break-word">    s/^[ |        ]*$%%3[ | ]*=[ |   ]*\(.*\)[ |     ]*/\1/p<br style="word-wrap:break-word">    }" $1<br style="word-wrap:break-word"> else<br style="word-wrap:break-word">        if [ "$%%4" = "#" ];then<br style="word-wrap:break-word">             sed "/\[$%%2\]/,/\[.*\]/{<br style="word-wrap:break-word">             s/^[ |        ]*$%%3[ |    ]*=.*/ /<br style="word-wrap:break-word">             }p" $1 > /tmp/sed$$<br style="word-wrap:break-word">             mv /tmp/sed$$ $1<br style="word-wrap:break-word">        else<br style="word-wrap:break-word">             sed "/\[$2\]/,/\[.*\]/{<br style="word-wrap:break-word">             s/^[ |        ]*$%%3[ |    ]*=.*/$%%3=$%%4/<br style="word-wrap:break-word">             }p" $1 > /tmp/sed$$<br style="word-wrap:break-word">             mv /tmp/sed$$ $%%1<br style="word-wrap:break-word">        fi<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 34.合并一个文件下所有的文件<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> cat $(ls |grep -E '%%1\.') > %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find %%1 -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> for file in $path/*.c $path/*.cpp<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [[ ! "$file" =~ \*.[A-Za-z]+ ]]; then<br style="word-wrap:break-word"> #"$(path)/$(file)"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> cat <<'EOF'> combine.c<br style="word-wrap:break-word"> #include<stdio.h><br style="word-wrap:break-word"> int main()<br style="word-wrap:break-word"> {<br style="word-wrap:break-word"> FILE *f1,*f2,*f3;<br style="word-wrap:break-word"> f1=fopen("a1.txt","r");<br style="word-wrap:break-word"> f2=fopen("a2.txt","r");<br style="word-wrap:break-word"> f3=fopen("a3.txt","w");<br style="word-wrap:break-word"> int a,b;<br style="word-wrap:break-word"> a=getw(f1);   /*从a1.txt和a2.txt中分别取最小的数a和b*/<br style="word-wrap:break-word"> b=getw(f2);<br style="word-wrap:break-word"> while(!feof(f1)&&!feof(f2))  /*两个文件都没结束时,执行循环、比较*/<br style="word-wrap:break-word"> {<br style="word-wrap:break-word"> if(a<=b)<br style="word-wrap:break-word"> {<br style="word-wrap:break-word"> putw(a,f3);<br style="word-wrap:break-word"> a=getw(f1);<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> {putw(b,f3);<br style="word-wrap:break-word"> b=getw(f2);<br style="word-wrap:break-word"> }<br style="word-wrap:break-word">    }<br style="word-wrap:break-word"> if(feof(f1))  /*文件a1.txt结束时,把a2.txt中的数全部输入a3.txt*/<br style="word-wrap:break-word"> {putw(b,f3);<br style="word-wrap:break-word"> while((b=getw(f2))!=EOF)<br style="word-wrap:break-word"> putw(b,f3);<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> if(feof(f2))   /*同上*/<br style="word-wrap:break-word"> {<br style="word-wrap:break-word"> putw(a,f3);<br style="word-wrap:break-word"> while((a=getw(f1))!=EOF)<br style="word-wrap:break-word"> putw(a,f3);<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> fclose(f1);<br style="word-wrap:break-word"> fclose(f2);<br style="word-wrap:break-word"> fclose(f3);<br style="word-wrap:break-word"> printf("已完成!");<br style="word-wrap:break-word"> return 0;<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> EOF<br style="word-wrap:break-word"> gcc -o combine combine.c<br style="word-wrap:break-word"> if [ $? -eq 0 ]; then<br style="word-wrap:break-word"> ./combine<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> echo 'Compile ERROR'<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 35.写入ini文件属性<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> if [ "$%%3" = "" ];then<br style="word-wrap:break-word">    sed -n "/\[$%%2\]/,/\[.*\]/{<br style="word-wrap:break-word">    /^\[.*\]/d<br style="word-wrap:break-word">    /^[ ]*$/d<br style="word-wrap:break-word">    s/;.*$//<br style="word-wrap:break-word">    p<br style="word-wrap:break-word">    }" $1<br style="word-wrap:break-word"> elif [ "$%%4" = "" ];then<br style="word-wrap:break-word">    sed -n "/\[$%%2\]/,/\[.*\]/{<br style="word-wrap:break-word">    /^\[.*\]/d<br style="word-wrap:break-word">    /^[ ]*$/d<br style="word-wrap:break-word">    s/;.*$//<br style="word-wrap:break-word">    s/^[ |        ]*$%%3[ | ]*=[ |   ]*\(.*\)[ |     ]*/\1/p<br style="word-wrap:break-word">    }" $1<br style="word-wrap:break-word"> else<br style="word-wrap:break-word">        if [ "$%%4" = "#" ];then<br style="word-wrap:break-word">             sed "/\[$%%2\]/,/\[.*\]/{<br style="word-wrap:break-word">             s/^[ |        ]*$%%3[ |    ]*=.*/ /<br style="word-wrap:break-word">             }p" $1 > /tmp/sed$$<br style="word-wrap:break-word">             mv /tmp/sed$$ $%%1<br style="word-wrap:break-word">        else<br style="word-wrap:break-word">             sed "/\[$%%2\]/,/\[.*\]/{<br style="word-wrap:break-word">             s/^[ |        ]*$%%3[ |    ]*=.*/$%%3=$%%4/<br style="word-wrap:break-word">             }p" $1 > /tmp/sed$$<br style="word-wrap:break-word">             mv /tmp/sed$$ $%%1<br style="word-wrap:break-word">        fi<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 36.获得当前路径<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> %%1=$(pwd)<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 37.读取XML数据库<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 如何通过shell命令行读取xml文件中某个属性所对应的值?<br style="word-wrap:break-word"> 例如:<br style="word-wrap:break-word"> <key>BuildVersion</key> <string>5</string><br style="word-wrap:break-word"> 我希望能够通过Unix shell命令对属性键的名称BuildVersion进行查询,返回的结果是5,如何实现呀?<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> grep BuildVersion|sed 's/.*<.*>\([^<].*\)<.*>.*/\1/'<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 结果返回的是“BuildVersion”,而不是“5”,如果要查询BuildVersion自动返回数值5应当如何写?<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 应该没错的。试一下: echo "<key>BuildVersion</key> <string>5</string>"|grep BuildVersion|sed 's/.*<.*>\([^<].*\)<.*>.*/\1/'我在SL的终端里试,返回值是5<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 目前需要从xml文件提取数据,想做一个xmlparser.sh<br style="word-wrap:break-word"> xml 类似这样<br style="word-wrap:break-word"> <result><br style="word-wrap:break-word">    <shareinfo hostip="192.168.0.1" sharename="abcd" password="abc123"></shareinfo><br style="word-wrap:break-word"> </result><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 希望输入 xmlparser.sh a.xml hostip可以返回192.168.0.1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> if [ $# -ne 2 ];then<br style="word-wrap:break-word">    echo "Usage: $0 <xmlfile> <key>"<br style="word-wrap:break-word">    exit 0<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> grep $2 $1|awk '{print $2}'|grep -o "[0-9.]*"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 把<br style="word-wrap:break-word"> grep $2 $1|awk '{print $2}'|grep -o "[0-9.]*"<br style="word-wrap:break-word"> 改成<br style="word-wrap:break-word"> grep $2 $1|awk '{print $2}'|grep -Eo "[0-9.]+"<br style="word-wrap:break-word"> 楼上这个有问题,如果我要得到的是<br style="word-wrap:break-word"> <result><br style="word-wrap:break-word">    <shareinfo hostip="192.168.0.1" sharename="abcd" password="abc123"></shareinfo><br style="word-wrap:break-word"> </result><br style="word-wrap:break-word"> 中的sharename,那么,呵呵,就错了<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 我觉得应该先定位到第二个参数“$2”的位置,然后再提取“=”后面的内容<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 这里有个完整的实现:<br style="word-wrap:break-word"> Parse Simple XML Files using Bash – Extract Name Value Pairs and Attributes<br style="word-wrap:break-word"> http://www.humbug.in/2010/parse-simple-xml-files-using-bash-extract-name-value-pairs-and-attributes/<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 不过需要安装xmllint.<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 设计到对多个xml文件进行element的读取和列表。有人做过么?<br style="word-wrap:break-word"> 举个例子,<br style="word-wrap:break-word"> 多个xml文件里面都有<br style="word-wrap:break-word"> <article><br style="word-wrap:break-word">         <title>xxx</titlel><br style="word-wrap:break-word"> </article><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 通过shell读取,然后合并到一起,再生成一个新的xml,但是其他元素不变。<br style="word-wrap:break-word"> <article><br style="word-wrap:break-word">         <title>aaa</titlel><br style="word-wrap:break-word"> </article><br style="word-wrap:break-word"> <article><br style="word-wrap:break-word">         <title>bbb</titlel><br style="word-wrap:break-word"> </article><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 如果格式异常简单,没有特例,那么可以用shell实现<br style="word-wrap:break-word"> 如果有可能格式复杂,因为shell的命令所使用的正则表达式都不支持跨行匹配,所以用shell来解决这个问题就绕圈子了。<br style="word-wrap:break-word"> 用perl来作这个工作最直接、简单。perl的XML:DOM模块是专门处理XML文件的。<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 偶倒是觉得,用PHP写Scripts也很方便,功能强大,而且,跨平台,<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> sed -n '/<article>/{<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> N;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> /\n[[:space:]]*<title>/{<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     N;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     /<article>.*<\/article>/p<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     }<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> D;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> n<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> }'<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 这小段代码能把一个xml文件中,你要的东西拿出来.<br style="word-wrap:break-word"> 你可以用for file in $*把这些信息都>>tmpfile中.<br style="word-wrap:break-word"> 然后用sed 在指定文件的指定位置用r命令把tmpfile粘贴进来~~~~<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 大思路如此^_^  我想有这个东西(只要能正确的跑出结果)后面就不难了吧...<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Name<br style="word-wrap:break-word"> xmllint — command line XML tool<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Synopsis<br style="word-wrap:break-word"> xmllint [[--version] | [--debug] | [--shell] | [--debugent] | [--copy] | [--recover] | [--noent] | [--noout] | [--nonet] | [--htmlout] | [--nowrap] | [--valid] | [--postvalid] | [--dtdvalid URL] | [--dtdvalidfpi FPI] | [--timing] | [--output file] | [--repeat] | [--insert] | [--compress] | [--html] | [--xmlout] | [--push] | [--memory] | [--maxmem nbbytes] | [--nowarning] | [--noblanks] | [--nocdata] | [--format] | [--encode encoding] | [--dropdtd] | [--nsclean] | [--testIO] | [--catalogs] | [--nocatalogs] | [--auto] | [--xinclude] | [--noxincludenode] | [--loaddtd] | [--dtdattr] | [--stream] | [--walker] | [--pattern patternvalue] | [--chkregister] | [--relaxng] | [--schema] | [--c14n]] [xmlfile]<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Introduction<br style="word-wrap:break-word"> The xmllint program parses one or more XML files, specified on the command line as xmlfile. It prints various types of output, depending upon the options selected. It is useful for detecting errors both in XML code and in the XML parser itself.<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> It is included in libxml2.<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Options<br style="word-wrap:break-word"> --version<br style="word-wrap:break-word"> Display the version of libxml2 used.<br style="word-wrap:break-word"> --debug<br style="word-wrap:break-word"> Parse a file and output an annotated tree of the in-memory version of the document.<br style="word-wrap:break-word"> --shell<br style="word-wrap:break-word"> Run a navigating shell. Details on available commands in shell mode are below.<br style="word-wrap:break-word"> --debugent<br style="word-wrap:break-word"> Debug the entities defined in the document.<br style="word-wrap:break-word"> --copy<br style="word-wrap:break-word"> Test the internal copy implementation.<br style="word-wrap:break-word"> --recover<br style="word-wrap:break-word"> Output any parsable portions of an invalid document.<br style="word-wrap:break-word"> --noent<br style="word-wrap:break-word"> Substitute entity values for entity references. By default, xmllint leaves entity references in place.<br style="word-wrap:break-word"> --nocdata<br style="word-wrap:break-word"> Substitute CDATA section by equivalent text nodes.<br style="word-wrap:break-word"> --nsclean<br style="word-wrap:break-word"> Remove redundant namespace declarations.<br style="word-wrap:break-word"> --noout<br style="word-wrap:break-word"> Suppress output. By default, xmllint outputs the result tree.<br style="word-wrap:break-word"> --htmlout<br style="word-wrap:break-word"> Output results as an HTML file. This causes xmllint to output the necessary HTML tags surrounding the result tree output so the results can be displayed in a browser.<br style="word-wrap:break-word"> --nowrap<br style="word-wrap:break-word"> Do not output HTML doc wrapper.<br style="word-wrap:break-word"> --valid<br style="word-wrap:break-word"> Determine if the document is a valid instance of the included Document Type Definition (DTD). A DTD to be validated against also can be specified at the command line using the --dtdvalid option. By default, xmllint also checks to determine if the document is well-formed.<br style="word-wrap:break-word"> --postvalid<br style="word-wrap:break-word"> Validate after parsing is completed.<br style="word-wrap:break-word"> --dtdvalid URL<br style="word-wrap:break-word"> Use the DTD specified by URL for validation.<br style="word-wrap:break-word"> --dtdvalidfpi FPI<br style="word-wrap:break-word"> Use the DTD specified by the Public Identifier FPI for validation, note that this will require a Catalog exporting that Public Identifier to work.<br style="word-wrap:break-word"> --timing<br style="word-wrap:break-word"> Output information about the time it takes xmllint to perform the various steps.<br style="word-wrap:break-word"> --output file<br style="word-wrap:break-word"> Define a file path where xmllint will save the result of parsing. Usually the programs build a tree and save it on stdout, with this option the result XML instance will be saved onto a file.<br style="word-wrap:break-word"> --repeat<br style="word-wrap:break-word"> Repeat 100 times, for timing or profiling.<br style="word-wrap:break-word"> --insert<br style="word-wrap:break-word"> Test for valid insertions.<br style="word-wrap:break-word"> --compress<br style="word-wrap:break-word"> Turn on gzip compression of output.<br style="word-wrap:break-word"> --html<br style="word-wrap:break-word"> Use the HTML parser.<br style="word-wrap:break-word"> --xmlout<br style="word-wrap:break-word"> Used in conjunction with --html. Usually when HTML is parsed the document is saved with the HTML serializer, but with this option the resulting document is saved with the XML serializer. This is primarily used to generate XHTML from HTML input.<br style="word-wrap:break-word"> --push<br style="word-wrap:break-word"> Use the push mode of the parser.<br style="word-wrap:break-word"> --memory<br style="word-wrap:break-word"> Parse from memory.<br style="word-wrap:break-word"> --maxmem nnbytes<br style="word-wrap:break-word"> Test the parser memory support. nnbytes is the maximum number of bytes the library is allowed to allocate. This can also be used to make sure batch processing of XML files will not exhaust the virtual memory of the server running them.<br style="word-wrap:break-word"> --nowarning<br style="word-wrap:break-word"> Do not emit warnings from the parser and/or validator.<br style="word-wrap:break-word"> --noblanks<br style="word-wrap:break-word"> Drop ignorable blank spaces.<br style="word-wrap:break-word"> --format<br style="word-wrap:break-word"> Reformat and reindent the output. The $XMLLINT_INDENT environment variable controls the indentation (default value is two spaces " ").<br style="word-wrap:break-word"> --testIO<br style="word-wrap:break-word"> Test user input/output support.<br style="word-wrap:break-word"> --encode encoding<br style="word-wrap:break-word"> Output in the given encoding.<br style="word-wrap:break-word"> --catalogs<br style="word-wrap:break-word"> Use the catalogs from $SGML_CATALOG_FILES. Otherwise /etc/xml/catalog is used by default.<br style="word-wrap:break-word"> --nocatalogs<br style="word-wrap:break-word"> Do not use any catalogs.<br style="word-wrap:break-word"> --auto<br style="word-wrap:break-word"> Generate a small document for testing purposes.<br style="word-wrap:break-word"> --xinclude<br style="word-wrap:break-word"> Do XInclude processing.<br style="word-wrap:break-word"> --noxincludenode<br style="word-wrap:break-word"> Do XInclude processing but do not generate XInclude start and end nodes.<br style="word-wrap:break-word"> --loaddtd<br style="word-wrap:break-word"> Fetch external DTD.<br style="word-wrap:break-word"> --dtdattr<br style="word-wrap:break-word"> Fetch external DTD and populate the tree with inherited attributes.<br style="word-wrap:break-word"> --dropdtd<br style="word-wrap:break-word"> Remove DTD from output.<br style="word-wrap:break-word"> --stream<br style="word-wrap:break-word"> Use streaming API - useful when used in combination with --relaxng or --valid options for validation of files that are too large to be held in memory.<br style="word-wrap:break-word"> --walker<br style="word-wrap:break-word"> Test the walker module, which is a reader interface but for a document tree, instead of using the reader API on an unparsed document it works on a existing in-memory tree. Used in debugging.<br style="word-wrap:break-word"> --chkregister<br style="word-wrap:break-word"> Turn on node registration. Useful for developers testing libxml2 node tracking code.<br style="word-wrap:break-word"> --pattern patternvalue<br style="word-wrap:break-word"> Used to exercise the pattern recognition engine, which can be used with the reader interface to the parser. It allows to select some nodes in the document based on an XPath (subset) expression. Used for debugging.<br style="word-wrap:break-word"> --relaxng schema<br style="word-wrap:break-word"> Use RelaxNG file named schema for validation.<br style="word-wrap:break-word"> --schema schema<br style="word-wrap:break-word"> Use a W3C XML Schema file named schema for validation.<br style="word-wrap:break-word"> --c14n<br style="word-wrap:break-word"> Use the W3C XML Canonicalisation (C14N) to serialize the result of parsing to stdout. It keeps comments in the result.<br style="word-wrap:break-word"> Shell<br style="word-wrap:break-word"> xmllint offers an interactive shell mode invoked with the --shell command. Available commands in shell mode include:<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> base<br style="word-wrap:break-word"> display XML base of the node<br style="word-wrap:break-word"> bye<br style="word-wrap:break-word"> leave shell<br style="word-wrap:break-word"> cat node<br style="word-wrap:break-word"> Display node if given or current node.<br style="word-wrap:break-word"> cd path<br style="word-wrap:break-word"> Change the current node to path (if given and unique) or root if no argument given.<br style="word-wrap:break-word"> dir path<br style="word-wrap:break-word"> Dumps information about the node (namespace, attributes, content).<br style="word-wrap:break-word"> du path<br style="word-wrap:break-word"> Show the structure of the subtree under path or the current node.<br style="word-wrap:break-word"> exit<br style="word-wrap:break-word"> Leave the shell.<br style="word-wrap:break-word"> help<br style="word-wrap:break-word"> Show this help.<br style="word-wrap:break-word"> free<br style="word-wrap:break-word"> Display memory usage.<br style="word-wrap:break-word"> load name<br style="word-wrap:break-word"> Load a new document with the given name.<br style="word-wrap:break-word"> ls path<br style="word-wrap:break-word"> List contents of path (if given) or the current directory.<br style="word-wrap:break-word"> pwd<br style="word-wrap:break-word"> Display the path to the current node.<br style="word-wrap:break-word"> quit<br style="word-wrap:break-word"> Leave the shell.<br style="word-wrap:break-word"> save name<br style="word-wrap:break-word"> Saves the current document to name if given or to the original name.<br style="word-wrap:break-word"> validate<br style="word-wrap:break-word"> Check the document for error.<br style="word-wrap:break-word"> write name<br style="word-wrap:break-word"> Write the current node to the given filename.<br style="word-wrap:break-word"> Catalogs<br style="word-wrap:break-word"> Catalog behavior can be changed by redirecting queries to the user's own set of catalogs. This can be done by setting the XML_CATALOG_FILES environment variable to a list of catalogs. An empty one should deactivate loading the default /etc/xml/catalog default catalog.<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Debugging Catalogs<br style="word-wrap:break-word"> Setting the environment variable XML_DEBUG_CATALOG using the command "export XML_DEBUG_CATALOG=" outputs debugging information related to catalog operations.<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Error Return Codes<br style="word-wrap:break-word"> On the completion of execution, Xmllint returns the following error codes:<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 0<br style="word-wrap:break-word"> No error<br style="word-wrap:break-word"> 1<br style="word-wrap:break-word"> Unclassified<br style="word-wrap:break-word"> 2<br style="word-wrap:break-word"> Error in DTD<br style="word-wrap:break-word"> 3<br style="word-wrap:break-word"> Validation error<br style="word-wrap:break-word"> 4<br style="word-wrap:break-word"> Validation error<br style="word-wrap:break-word"> 5<br style="word-wrap:break-word"> Error in schema compilation<br style="word-wrap:break-word"> 6<br style="word-wrap:break-word"> Error writing output<br style="word-wrap:break-word"> 7<br style="word-wrap:break-word"> Error in pattern (generated when [--pattern] option is used)<br style="word-wrap:break-word"> 8<br style="word-wrap:break-word"> Error in Reader registration (generated when [--chkregister] option is used)<br style="word-wrap:break-word"> 9<br style="word-wrap:break-word"> Out of memory error<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Parse Simple XML Files using Bash – Extract Name Value Pairs and Attributes<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 2 Comments<br style="word-wrap:break-word"> 1<br style="word-wrap:break-word"> Tweet<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> Pratik Sinha | July 31, 2010<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> I have written up a simple routine par***ML to parse simple XML files to extract unique name values pairs and their attributes. The script extracts all xml tags of the format <abc arg1="hello">xyz</abc> and dynamically creates bash variables which hold values of the attributes as well as the elements. This is a good solution, if you don’t wish to use xpath for some simple xml files. However you will need xmllint installed on your system to use the script. Here’s a sample script which uses the par***ML function<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> xmlFile=$1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> function par***ML() {<br style="word-wrap:break-word">   elemList=( $(cat $xmlFile | tr '\n' ' ' | XMLLINT_INDENT="" xmllint --format - | /bin/grep -e "</.*>$" | while read line; do \<br style="word-wrap:break-word">     echo $line | sed -e 's/^.*<\///' | cut -d '>' -f 1; \<br style="word-wrap:break-word">   done) )<br style="word-wrap:break-word"> <br style="word-wrap:break-word">   totalNoOfTags=${#elemList[@]}; ((totalNoOfTags--))<br style="word-wrap:break-word">   suffix=$(echo ${elemList[$totalNoOfTags]} | tr -d '</>')<br style="word-wrap:break-word">   suffix="${suffix}_"<br style="word-wrap:break-word"> <br style="word-wrap:break-word">   for (( i = 0 ; i < ${#elemList[@]} ; i++ )); do<br style="word-wrap:break-word">     elem=${elemList[$i]}<br style="word-wrap:break-word">     elemLine=$(cat $xmlFile | tr '\n' ' ' | XMLLINT_INDENT="" xmllint --format - | /bin/grep "</$elem>")<br style="word-wrap:break-word">     echo $elemLine | grep -e "^</[^ ]*>$" 1>/dev/null 2>&1<br style="word-wrap:break-word">     if [ "0" = "$?" ]; then<br style="word-wrap:break-word">       continue<br style="word-wrap:break-word">     fi<br style="word-wrap:break-word">     elemVal=$(echo $elemLine | tr '\011' '\040'| sed -e 's/^[ ]*//' -e 's/^<.*>\([^<].*\)<.*>$/\1/' | sed -e 's/^[ ]*//' | sed -e 's/[ ]*$//')<br style="word-wrap:break-word">     xmlElem="${suffix}$(echo $elem | sed 's/-/_/g')"<br style="word-wrap:break-word">     eval ${xmlElem}=`echo -ne \""${elemVal}"\"`<br style="word-wrap:break-word">     attrList=($(cat $xmlFile | tr '\n' ' ' | XMLLINT_INDENT="" xmllint --format - | /bin/grep "</$elem>" | tr '\011' '\040' | sed -e 's/^[ ]*//' | cut -d '>' -f 1  | sed -e 's/^<[^ ]*//' | tr "'" '"' | tr '"' '\n'  | tr '=' '\n' | sed -e 's/^[ ]*//' | sed '/^$/d' | tr '\011' '\040' | tr ' ' '>'))<br style="word-wrap:break-word">     for (( j = 0 ; j < ${#attrList[@]} ; j++ )); do<br style="word-wrap:break-word">       attr=${attrList[$j]}<br style="word-wrap:break-word">       ((j++))<br style="word-wrap:break-word">       attrVal=$(echo ${attrList[$j]} | tr '>' ' ')<br style="word-wrap:break-word">       attrName=`echo -ne ${xmlElem}_${attr}`<br style="word-wrap:break-word">       eval ${attrName}=`echo -ne \""${attrVal}"\"`<br style="word-wrap:break-word">     done<br style="word-wrap:break-word">   done<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> par***ML<br style="word-wrap:break-word"> echo "$status_xyz |  $status_abc |  $status_pqr" #Variables for each  XML ELement<br style="word-wrap:break-word"> echo "$status_xyz_arg1 |  $status_abc_arg2 |  $status_pqr_arg3 | $status_pqr_arg4" #Variables for each XML Attribute<br style="word-wrap:break-word"> echo ""<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #All the variables that were produced by the par***ML function<br style="word-wrap:break-word"> set | /bin/grep -e "^$suffix"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> The XML File used for the above script example is:<br style="word-wrap:break-word"> <?xml version="1.0"?><br style="word-wrap:break-word"> <status><br style="word-wrap:break-word">   <xyz arg1="1"> a </xyz><br style="word-wrap:break-word">   <abc arg2="2"> p </abc><br style="word-wrap:break-word">   <pqr arg3="3" arg4="a phrase"> x </pqr><br style="word-wrap:break-word"> </status><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> The root tag, which in this case is “status”, is used as a suffix for all variables. Once the XML file is passed to the function, it dynamically creates the variables $status_xyz, $status_abc, $status_pqr, $status_xyz_arg1, $status_abc_arg2, $status_pqr_arg3 and $status_pqr_arg4.<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> The output when the script is ran with the xml file as an argument is<br style="word-wrap:break-word"> @$ bash  par***ML.sh test.xml<br style="word-wrap:break-word"> a |  p |  x<br style="word-wrap:break-word"> 1 |  2 |  3 | a phrase<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> status_abc=p<br style="word-wrap:break-word"> status_abc_arg2=2<br style="word-wrap:break-word"> status_pqr=x<br style="word-wrap:break-word"> status_pqr_arg3=3<br style="word-wrap:break-word"> status_pqr_arg4='a phrase'<br style="word-wrap:break-word"> status_xyz=a<br style="word-wrap:break-word"> status_xyz_arg1=1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> This script won’t work for XML files like the one below with duplicate element names.<br style="word-wrap:break-word"> <?xml version="1.0"?><br style="word-wrap:break-word"> <status><br style="word-wrap:break-word">   <test arg1="1"> a </test><br style="word-wrap:break-word">   <test arg2="2"> p </test><br style="word-wrap:break-word">   <test arg3="3" arg4="a phrase"> x </test><br style="word-wrap:break-word"> </status><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> This script also won’t be able to extract attributes of elements without any CDATA. For eg, the script won’t be able to create variables corresponding to <test arg1="1">. It will only create the variables corresponding to <test1 arg2="2">abc</test1>.<br style="word-wrap:break-word"> <?xml version="1.0"?><br style="word-wrap:break-word"> <status><br style="word-wrap:break-word">   <test arg1="1"><br style="word-wrap:break-word">     <test1 arg2="2">abc</test1><br style="word-wrap:break-word">   </test><br style="word-wrap:break-word"> </status><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 38.写入XML数据库<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 39.ZIP压缩文件<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> zip -r "/%%1" "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 40.ZIP解压缩<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> unzip -x "/%%1" "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 41.获得应用程序完整路径<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 42.ZIP压缩文件夹<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 43.递归删除目录下的文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rm -if "%%1/*"<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find %%1 -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> for file in $path/*.c $path/*.cpp<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [[ ! "$file" =~ \*.[A-Za-z]+ ]]; then<br style="word-wrap:break-word"> #"$(path)/$(file)"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 44.IDEA加密算法<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 45.RC6算法<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> cat <<'EOF'> rc6.c<br style="word-wrap:break-word"> #include<stdio.h><br style="word-wrap:break-word"> /* Timing data for RC6 (rc6.c)<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 128 bit key:<br style="word-wrap:break-word"> Key Setup:    1632 cycles<br style="word-wrap:break-word"> Encrypt:       270 cycles =    94.8 mbits/sec<br style="word-wrap:break-word"> Decrypt:       226 cycles =   113.3 mbits/sec<br style="word-wrap:break-word"> Mean:          248 cycles =   103.2 mbits/sec<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 192 bit key:<br style="word-wrap:break-word"> Key Setup:    1885 cycles<br style="word-wrap:break-word"> Encrypt:       267 cycles =    95.9 mbits/sec<br style="word-wrap:break-word"> Decrypt:       235 cycles =   108.9 mbits/sec<br style="word-wrap:break-word"> Mean:          251 cycles =   102.0 mbits/sec<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 256 bit key:<br style="word-wrap:break-word"> Key Setup:    1877 cycles<br style="word-wrap:break-word"> Encrypt:       270 cycles =    94.8 mbits/sec<br style="word-wrap:break-word"> Decrypt:       227 cycles =   112.8 mbits/sec<br style="word-wrap:break-word"> Mean:          249 cycles =   103.0 mbits/sec<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> */<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #include "../std_defs.h"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> static char *alg_name[] = { "rc6", "rc6.c", "rc6" };<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> char **cipher_name()<br style="word-wrap:break-word"> {<br style="word-wrap:break-word">     return alg_name;<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #define f_rnd(i,a,b,c,d)                    \<br style="word-wrap:break-word">         u = rotl(d * (d + d + 1), 5);       \<br style="word-wrap:break-word">         t = rotl(b * (b + b + 1), 5);       \<br style="word-wrap:break-word">         a = rotl(a ^ t, u) + l_key;      \<br style="word-wrap:break-word">         c = rotl(c ^ u, t) + l_key[i + 1]<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #define i_rnd(i,a,b,c,d)                    \<br style="word-wrap:break-word">         u = rotl(d * (d + d + 1), 5);       \<br style="word-wrap:break-word">         t = rotl(b * (b + b + 1), 5);       \<br style="word-wrap:break-word">         c = rotr(c - l_key[i + 1], t) ^ u;  \<br style="word-wrap:break-word">         a = rotr(a - l_key, u) ^ t<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> u4byte  l_key[44];  /* storage for the key schedule         */<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> /* initialise the key schedule from the user supplied key   */<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> u4byte *set_key(const u4byte in_key[], const u4byte key_len)<br style="word-wrap:break-word"> {   u4byte  i, j, k, a, b, l[8], t;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     l_key[0] = 0xb7e15163;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     for(k = 1; k < 44; ++k)<br style="word-wrap:break-word">        <br style="word-wrap:break-word">         l_key[k] = l_key[k - 1] + 0x9e3779b9;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     for(k = 0; k < key_len / 32; ++k)<br style="word-wrap:break-word"> <br style="word-wrap:break-word">         l[k] = in_key[k];<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     t = (key_len / 32) - 1; // t = (key_len / 32);<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     a = b = i = j = 0;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     for(k = 0; k < 132; ++k)<br style="word-wrap:break-word">     {   a = rotl(l_key + a + b, 3); b += a;<br style="word-wrap:break-word">         b = rotl(l[j] + b, b);<br style="word-wrap:break-word">         l_key = a; l[j] = b;<br style="word-wrap:break-word">         i = (i == 43 ? 0 : i + 1); // i = (i + 1) % 44; <br style="word-wrap:break-word">         j = (j == t ? 0 : j + 1);  // j = (j + 1) % t;<br style="word-wrap:break-word">     }<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     return l_key;<br style="word-wrap:break-word"> };<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> /* encrypt a block of text  */<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> void encrypt(const u4byte in_blk[4], u4byte out_blk[4])<br style="word-wrap:break-word"> {   u4byte  a,b,c,d,t,u;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     a = in_blk[0]; b = in_blk[1] + l_key[0];<br style="word-wrap:break-word">     c = in_blk[2]; d = in_blk[3] + l_key[1];<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     f_rnd( 2,a,b,c,d); f_rnd( 4,b,c,d,a);<br style="word-wrap:break-word">     f_rnd( 6,c,d,a,b); f_rnd( 8,d,a,b,c);<br style="word-wrap:break-word">     f_rnd(10,a,b,c,d); f_rnd(12,b,c,d,a);<br style="word-wrap:break-word">     f_rnd(14,c,d,a,b); f_rnd(16,d,a,b,c);<br style="word-wrap:break-word">     f_rnd(18,a,b,c,d); f_rnd(20,b,c,d,a);<br style="word-wrap:break-word">     f_rnd(22,c,d,a,b); f_rnd(24,d,a,b,c);<br style="word-wrap:break-word">     f_rnd(26,a,b,c,d); f_rnd(28,b,c,d,a);<br style="word-wrap:break-word">     f_rnd(30,c,d,a,b); f_rnd(32,d,a,b,c);<br style="word-wrap:break-word">     f_rnd(34,a,b,c,d); f_rnd(36,b,c,d,a);<br style="word-wrap:break-word">     f_rnd(38,c,d,a,b); f_rnd(40,d,a,b,c);<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     out_blk[0] = a + l_key[42]; out_blk[1] = b;<br style="word-wrap:break-word">     out_blk[2] = c + l_key[43]; out_blk[3] = d;<br style="word-wrap:break-word"> };<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> /* decrypt a block of text  */<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> void decrypt(const u4byte in_blk[4], u4byte out_blk[4])<br style="word-wrap:break-word"> {   u4byte  a,b,c,d,t,u;<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     d = in_blk[3]; c = in_blk[2] - l_key[43];<br style="word-wrap:break-word">     b = in_blk[1]; a = in_blk[0] - l_key[42];<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     i_rnd(40,d,a,b,c); i_rnd(38,c,d,a,b);<br style="word-wrap:break-word">     i_rnd(36,b,c,d,a); i_rnd(34,a,b,c,d);<br style="word-wrap:break-word">     i_rnd(32,d,a,b,c); i_rnd(30,c,d,a,b);<br style="word-wrap:break-word">     i_rnd(28,b,c,d,a); i_rnd(26,a,b,c,d);<br style="word-wrap:break-word">     i_rnd(24,d,a,b,c); i_rnd(22,c,d,a,b);<br style="word-wrap:break-word">     i_rnd(20,b,c,d,a); i_rnd(18,a,b,c,d);<br style="word-wrap:break-word">     i_rnd(16,d,a,b,c); i_rnd(14,c,d,a,b);<br style="word-wrap:break-word">     i_rnd(12,b,c,d,a); i_rnd(10,a,b,c,d);<br style="word-wrap:break-word">     i_rnd( 8,d,a,b,c); i_rnd( 6,c,d,a,b);<br style="word-wrap:break-word">     i_rnd( 4,b,c,d,a); i_rnd( 2,a,b,c,d);<br style="word-wrap:break-word"> <br style="word-wrap:break-word">     out_blk[3] = d - l_key[1]; out_blk[2] = c;<br style="word-wrap:break-word">     out_blk[1] = b - l_key[0]; out_blk[0] = a;<br style="word-wrap:break-word"> };<br style="word-wrap:break-word"> int main()<br style="word-wrap:break-word"> {<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> return 0;<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> EOF<br style="word-wrap:break-word"> gcc -o rc6 rc6.c<br style="word-wrap:break-word"> if [ $? -eq 0 ]; then<br style="word-wrap:break-word"> ./combine<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> echo 'Compile ERROR'<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 46.Grep<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> grep -qE %%1 %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 47.直接创建多级目录<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> mkdir -p %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 48.批量重命名<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find $PWD -type f -name '*\.cpp' |sed s/'\.cpp'//g|awk '{MV = "mv"};{C = "\.c"};{ CPP="\.cpp"}; {print MV, $1 CPP , $1 C}'|sh<br style="word-wrap:break-word"> ls | awk -F '-' '{print "mv "$0" "$2}' #去掉带'-'的前缀<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 49.文本查找替换<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> sed -e 's:%%2:%%3:g' %%1<br style="word-wrap:break-word"> #sed -e 's/%%2/%%3/g' %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 50.文件关联<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 51.批量转换编码从GB2312到Unicode<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> scode="gbk"<br style="word-wrap:break-word"> dcode="ucs2"<br style="word-wrap:break-word"> for FILE in $(find $(pwd) -type f)<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> TMP_file=$(mktemp -p $(pwd))<br style="word-wrap:break-word"> if [ -f $FILE ]; then<br style="word-wrap:break-word"> Fright=$(stat -c %a $FILE)<br style="word-wrap:break-word"> Fuser=$(stat -c %U $FILE)<br style="word-wrap:break-word"> Fgrp=$(stat -c %G $FILE)<br style="word-wrap:break-word"> iconv -f $scode -t $dcode $FILE -o $TMP_file<br style="word-wrap:break-word"> mv $TMP_file $FILE<br style="word-wrap:break-word"> chmod $Fright $FILE<br style="word-wrap:break-word"> chown $Fuser.$Fgrp $FILE<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 52.设置JDK环境变量<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find "$PWD" -type f \( -iname '*.bin' \) -print0 | xargs -0 chmod +x<br style="word-wrap:break-word"> find -type f \( -iname '*.bin' \) -print |<br style="word-wrap:break-word"> while read filename<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     case "$filename" in<br style="word-wrap:break-word">     *.bin)<br style="word-wrap:break-word">         xterm -e "$filename" && rm -if "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     esac<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=$'\n'<br style="word-wrap:break-word"> for line in `cat ~/.bashrc`<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [[ "$line" =~ .*export.* ]]; then<br style="word-wrap:break-word">     if [[ "$line" =~ .*JAVA_HOME=.* ]]; then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]]; then<br style="word-wrap:break-word">        javahome=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     fi<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [[ "$line" =~ export\ PATH=\$PATH:\$JAVA_HOME/bin:\$JAVA_HOME/jre/bin$ ]];then<br style="word-wrap:break-word">     javapath=$line<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [[ "$line" =~ export\ CLASSPATH=.:\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib$ ]];then<br style="word-wrap:break-word">     classpath=$line<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> if [ ! -n "$javahome" ]; then<br style="word-wrap:break-word"> sed -i '$a export JAVA_HOME='$(pwd)'/jdk1.6.0_25' ~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${javahome//\\/\\\\}':export JAVA_HOME='$(pwd)'/jdk1.6.0_32:g' ~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$javapath" ]; then<br style="word-wrap:break-word"> sed -i '$a export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin' ~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$classpath" ]; then<br style="word-wrap:break-word"> sed -i '$a export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' ~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> shift<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=$'\n'<br style="word-wrap:break-word"> for line in `cat ~/TestBash.txt` #~/.bashrc<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">   if [[ "$line" =~ .*export.* ]]; then<br style="word-wrap:break-word">     if [[ "$line" =~ export\ CLASSPATH=.:\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib$ ]]; then<br style="word-wrap:break-word">       classpath=$line<br style="word-wrap:break-word">     elif [[ "$line" =~ export\ PATH=\$PATH:\$CATALINA_HOME/bin$ ]]; then<br style="word-wrap:break-word">       jbosspath=$line<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word">     if [[ "$line" =~ .*JAVA_HOME=.* ]]; then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]];then<br style="word-wrap:break-word">        javahome=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     elif [[ "$line" =~ .*CATALINA_HOME=.* ]];then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]];then<br style="word-wrap:break-word">        catalinahome=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     elif [[ "$line" =~ .*TOMCAT_HOME=.* ]];then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]];then<br style="word-wrap:break-word">        tomcathome=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     elif [[ "$line" =~ .*CATALINA_BASE=.* ]];then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]];then<br style="word-wrap:break-word">        catalinabase=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     elif [[ "$line" =~ .*JBOSS_HOME=.* ]];then<br style="word-wrap:break-word">       if [[ "$line" =~ =(\/([0-9a-zA-Z._]+))+ ]];then<br style="word-wrap:break-word">        jbosshome=$line<br style="word-wrap:break-word">       fi<br style="word-wrap:break-word">     fi<br style="word-wrap:break-word">   elif [[ "$line" =~ ^PATH=\$PATH:\$JAVA_HOME/bin:\$JAVA_HOME/jre/bin$ ]];then<br style="word-wrap:break-word">     javapath=$line<br style="word-wrap:break-word">   fi<br style="word-wrap:break-word">   if [[ "$line" =~ export\ CLASSPATH=.:\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib$ ]];then<br style="word-wrap:break-word">     classpath=$line<br style="word-wrap:break-word">   fi<br style="word-wrap:break-word">   if [[ "$line" =~ export\ PATH=\$PATH:\$JBOSS_HOME/bin$ ]];then<br style="word-wrap:break-word">     jbosspath=$line<br style="word-wrap:break-word">   fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> if [ ! -n "$javahome" ]; then<br style="word-wrap:break-word"> sed -i '$a export JAVA_HOME='$(pwd)'/jdk1.6.0_24' ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${javahome//\\/\\\\}':export JAVA_HOME='$(pwd)'/jdk1.6.0_24:g' ~/TestBash.txt<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$javapath" ]; then<br style="word-wrap:break-word"> sed -i '$a PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin' ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$classpath" ]; then<br style="word-wrap:break-word"> sed -i '$a export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$catalinahome" ]; then<br style="word-wrap:break-word"> sed -i '$a export CATALINA_HOME='$(pwd) ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${catalinahome//\\/\\\\}':export CATALINA_HOME='$(pwd)':g' ~/TestBash.txt<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$tomcathome" ]; then<br style="word-wrap:break-word"> sed -i '$a export TOMCAT_HOME='$(pwd) ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${tomcathome//\\/\\\\}':export TOMCAT_HOME='$(pwd)':g' ~/TestBash.txt<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$catalinabase" ]; then<br style="word-wrap:break-word"> sed -i '$a export CATALINA_BASE='$(pwd) ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${catalinabase//\\/\\\\}':export CATALINA_BASE='$(pwd)':g' ~/TestBash.txt<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$jbosshome" ]; then<br style="word-wrap:break-word"> sed -i '$a export JBOSS_HOME='$(pwd) ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> sed -i 's:'${jbosshome//\\/\\\\}':export JBOSS_HOME='$(pwd)':g' ~/TestBash.txt<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> if [ ! -n "$jbosspath" ]; then<br style="word-wrap:break-word"> sed -i '$a export PATH=$PATH:$CATALINA_HOME/bin' ~/TestBash.txt #~/.bashrc<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 53.批量转换编码从Unicode到GB2312<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> scode="ucs2"<br style="word-wrap:break-word"> dcode="gbk"<br style="word-wrap:break-word"> for FILE in $(find $(pwd) -type f)<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> TMP_file=$(mktemp -p $(pwd))<br style="word-wrap:break-word"> if [ -f $FILE ]; then<br style="word-wrap:break-word"> Fright=$(stat -c %a $FILE)<br style="word-wrap:break-word"> Fuser=$(stat -c %U $FILE)<br style="word-wrap:break-word"> Fgrp=$(stat -c %G $FILE)<br style="word-wrap:break-word"> iconv -f $scode -t $dcode $FILE -o $TMP_file<br style="word-wrap:break-word"> mv $TMP_file $FILE<br style="word-wrap:break-word"> chmod $Fright $FILE<br style="word-wrap:break-word"> chown $Fuser.$Fgrp $FILE<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 54.删除空文件夹<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rmdir -p %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 55.GB2312文件转UTF-8格式<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> iconv -f gbk -t utf8 %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 56.UTF-8文件转GB2312格式<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> iconv -f utf8 -t  gbk %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 57.获取文件路径的父路径<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> %%1=basename $PWD<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 58.Unicode文件转UTF-8格式<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> iconv -f ucs2 -t  utf-8 %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 59.CRC循环冗余校验<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> cat <<'EOF'> crc.c<br style="word-wrap:break-word"> #include<stdio.h><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int crc32_table[256]; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int ulPolynomial = 0x04c11db7; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int Reflect(unsigned long int ref, char ch) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   {     unsigned long int value(0); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         // 交换bit0和bit7,bit1和bit6,类推 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         for(int i = 1; i < (ch + 1); i++) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          {            if(ref & 1) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                       value |= 1 << (ch - i); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                    ref >>= 1;      } <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         return value; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> } <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> init_crc32_table() <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   {     unsigned long int crc,temp; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         // 256个值 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         for(int i = 0; i <= 0xFF; i++) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          {   temp=Reflect(i, 8); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                crc32_table[i]= temp<< 24; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 for (int j = 0; j < 8; j++){ <br style="word-wrap:break-word"> <br style="word-wrap:break-word">              unsigned long int t1,t2; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   unsigned long int flag=crc32_table[i]&0x80000000; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 t1=(crc32_table[i] << 1); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 if(flag==0) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                   t2=0; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 else <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                   t2=ulPolynomial; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 crc32_table[i] =t1^t2 ;        } <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                crc=crc32_table[i]; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                crc32_table[i] = Reflect(crc32_table[i], 32); <br style="word-wrap:break-word">         }<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> unsigned long GenerateCRC32(char xdata * DataBuf,unsigned long  len) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   { <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         unsigned long oldcrc32; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         unsigned long crc32; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         unsigned long oldcrc; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         unsigned  int charcnt; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          char c,t; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         oldcrc32 = 0x00000000; //初值为0 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">      charcnt=0; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          while (len--) { <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                  t= (oldcrc32 >> 24) & 0xFF;   //要移出的字节的值 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">      oldcrc=crc_32_tab[t];         //根据移出的字节的值查表 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                  c=DataBuf[charcnt];          //新移进来的字节值 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                  oldcrc32= (oldcrc32 << 8) | c;   //将新移进来的字节值添在寄存器末字节中 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                  oldcrc32=oldcrc32^oldcrc;     //将寄存器与查出的值进行xor运算 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                  charcnt++; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         } <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          crc32=oldcrc32; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          return crc32; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> } <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 参数表可以先在PC机上算出来,也可在程序初始化时完成。下面是用于计算参数表的c语言子程序,在Visual C++ 6.0下编译通过。 <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #include <stdio.h> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int crc32_table[256]; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int ulPolynomial = 0x04c11db7; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> unsigned long int Reflect(unsigned long int ref, char ch) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   {     unsigned long int value(0); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         // 交换bit0和bit7,bit1和bit6,类推 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         for(int i = 1; i < (ch + 1); i++) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          {            if(ref & 1) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                       value |= 1 << (ch - i); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                    ref >>= 1;      } <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         return value; <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> int main()<br style="word-wrap:break-word"> {<br style="word-wrap:break-word">      unsigned long int crc,temp; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         // 256个值 <br style="word-wrap:break-word"> <br style="word-wrap:break-word">         for(int i = 0; i <= 0xFF; i++) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">          {<br style="word-wrap:break-word"> temp=Reflect(i, 8);<br style="word-wrap:break-word">                crc32_table[i]= temp<< 24; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 for (int j = 0; j < 8; j++){ <br style="word-wrap:break-word"> <br style="word-wrap:break-word">              unsigned long int t1,t2; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">   unsigned long int flag=crc32_table[i]&0x80000000;<br style="word-wrap:break-word">                 t1=(crc32_table[i] << 1); <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 if(flag==0) <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                   t2=0; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 else <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                   t2=ulPolynomial; <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                 crc32_table[i] =t1^t2 ;       <br style="word-wrap:break-word"> } <br style="word-wrap:break-word"> <br style="word-wrap:break-word">                crc=crc32_table[i];<br style="word-wrap:break-word">                crc32_table[i] = Reflect(crc32_table[i], 32);<br style="word-wrap:break-word">         }<br style="word-wrap:break-word"> return 0;<br style="word-wrap:break-word"> }<br style="word-wrap:break-word"> EOF<br style="word-wrap:break-word"> gcc -o crc crc.c<br style="word-wrap:break-word"> if [ $? -eq 0 ]; then<br style="word-wrap:break-word"> ./combine<br style="word-wrap:break-word"> else<br style="word-wrap:break-word"> echo 'Compile ERROR'<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 60.判断是否为空文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 61.终止程序<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> kill -KILL pidof %%1 -s<br style="word-wrap:break-word"> #killall %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 62.定时关机<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> shutdown -h %%1 & #23:00<br style="word-wrap:break-word"> #shutdown -h now<br style="word-wrap:break-word"> #halt<br style="word-wrap:break-word"> #/sbin/poweroff<br style="word-wrap:break-word"> #init 0<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 63.显示进程列表<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> ps aux<br style="word-wrap:break-word"> #fuser -l<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 64.遍历文件夹列出文件大小<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> du -sH "%%1/*"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 65.GOST算法<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 66.对目标压缩文件解压缩到指定文件夹<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 67.保存文件时重名自动生成新文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 68.打开网页<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> lynx %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 69.删除空文件夹整合操作<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 70.获取磁盘所有分区<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> df -k<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 71.激活一个程序或程序关联的文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 72.MP3播放<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> amp "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 73.WAV播放<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> amp "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 74.写图像到剪切板<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 75.从剪贴板复制图像到窗体<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 76.删除文件夹下的所有文件且不删除文件夹下的文件夹<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> rm -if "%%1/*"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 77.XML遍历结点属性值<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 78.Unicode文件转GB2312格式<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> iconv -f ucs2 -t  gbk %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 79.开源程序库Xercesc-C++代码工程中内联80.提取包含头文件列表<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 81.GB2312文件转Unicode格式<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> iconv -f gbk -t  ucs2 %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 82.Java程序打包<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 83.UTF-8文件转Unicode格式<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> iconv -f utf8 -t  ucs2 %%1 -o %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 84.创建PDF文档<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 85.创建Word文档<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 86.快速高效的文件加密<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 87.从CSV文件构造XML文档<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 88.从XML文档生成CSV文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 89.模拟键盘输入字符串<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 90.提取PDF文件中的文本<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 91.操作内存映射文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> 91.1发送内存映射数据<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 91.2接收内存映射数据<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 92.重定向windows控制台程序的输出信息<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 93.基数转序数<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 94.数字月份转英文<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 95.报表相关<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 96.根据进程名获取进程ID<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> pidof %%1 -s<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 96.BCP导入<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 97.BCP导出<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 98.计算文件MD5值<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> md5sum "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 99.计算获取文件夹中文件的MD5值<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 100.复制一个目录下所有文件到一个文件夹中<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> cp $(find "%%1" -name *.*) "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 101.移动一个目录下所有文件到一个文件夹中<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> mv $(find "%%1" -name *.*) "%%2"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 102.文件RSA高级加密<br style="word-wrap:break-word"> 十进制到十六进制<br style="word-wrap:break-word"> typeset -i16 BASE_16_NUM<br style="word-wrap:break-word"> BASE_16_NUM=%%1<br style="word-wrap:break-word"> echo $BASE_16_NUM<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 八进制到十六进制<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> typeset -i16 BASE_16_NUM<br style="word-wrap:break-word"> BASE_16_NUM=8#%%1<br style="word-wrap:break-word"> echo $BASE_16_NUM<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 十进制到八进制<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> printf %o %%1; echo<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 十进制到十六进制<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> printf %x %%1; echo<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 103.计算文件大小<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> wc "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 104.计算文件夹的大小<br style="word-wrap:break-word"> #!/sbin/ksh<br style="word-wrap:break-word"> dir=%%1<br style="word-wrap:break-word"> (cd $dir;pwd)<br style="word-wrap:break-word"> find $dir -type d -print | du | awk '{print $2, "== ("$1/2"kb)"}' |sort -f |<br style="word-wrap:break-word"> sed -e "s,[^ /]*/([^ /]*) ==,|--1," -e"s,[^ /]*/,| ,g"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 105.快速获得当前程序的驱动器、路径、文件名和扩展名<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 106.磁盘剩余空间计算<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> df -k<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 107.获取当前程序进程ID<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> pidof %%1 -s<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 108.全盘搜索文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> #updatedb<br style="word-wrap:break-word"> #locate %%1<br style="word-wrap:break-word"> slocate %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 109.获得当前登录的用户名<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> whoami<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 110.获得所有用户名<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> who<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 111.创建MySQL管理用户<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> mysqladmin -u root password %%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 112.管理MySQL数据库服务器<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> 112.1.启动MySQL数据库服务器<br style="word-wrap:break-word"> mysqld -console<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 112.2.登录MySQL数据库服务器<br style="word-wrap:break-word"> 112.2.1.登录本地MySQL数据库服务器<br style="word-wrap:break-word"> mysql -uroot -p%%1<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 112.2.2.登录远程MySQL数据库服务器<br style="word-wrap:break-word"> mysql -h %%1 -u %%2 -p%%3<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 112.3.关闭MySQL数据库服务器<br style="word-wrap:break-word"> mysqladmin -u root shutdown<br style="word-wrap:break-word"> #pkill -9 mysql<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 112.4.测试MySQL数据库服务器<br style="word-wrap:break-word"> mysqlshow || mysqlshow -u root mysql || mysqladmin version status || mysql test<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 113.MySQL执行查询<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> mysqladmin -u %%1 -p%%2 SELECT * INTO OUTFILE './bestlovesky.xls' FROM bestlovesky WHERE 1 ORDER BY id DESC  LIMIT 0, 50;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> mysql -u %%1 -p%%2 -e "SELECT * INTO OUTFILE './bestlovesky.xls' FROM bestlovesky WHERE 1 ORDER BY id DESC  LIMIT 0, 50;"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 114.创建Oracle管理用户<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> 114.1.创建新用户<br style="word-wrap:break-word"> create user test identified by test default tablespace ts_test temporary<br style="word-wrap:break-word"> tablespace temp;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 114.2.给用户角色特权<br style="word-wrap:break-word"> grant connect,resource to test;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 115.登录Oracle数据库<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> sqlplusw<br style="word-wrap:break-word"> sqlplus /nolog<br style="word-wrap:break-word"> conn username/password@Oranet<br style="word-wrap:break-word"> conn system/systempwd@whfc<br style="word-wrap:break-word"> conn sys/syspwd@whfc as sysdba<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 115.创建Oracle表空间<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> conn system@whfc01<br style="word-wrap:break-word"> create tablespace ts_test datafile '/data2/oradata/ciis/ts_test01.dbf' size<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 116.添加Oracle数据文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> alter tablespace ts_test add datafile '/data2/oradata/ciis/ts_test02.dbf' size<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 117.查看Oracle表空间大小<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> desc DBA_DATA_FILES<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 118.查看Oracle剩余表空间大小<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> desc DBA_FREE_SPACE<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 119.查看Oracle当前用户表名<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> select * from tab;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 120.Oracle创建索引<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> CREATE INDEX idx_book_bookid ON book(bookname);<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 121.Oracle创建主键约束<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> ALTER TABLE book ADD CONSTRAINT pk_book_bookid PRIMARY KEY (bookid);<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 122.Oracle显示表结构<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> desc book<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 123.Oracle查看表的索引<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> column index_name format a30<br style="word-wrap:break-word"> select table_name, index_name from user_indexes;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 124.Oracle查看索引列<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> select table_name, index_name, column_name, column_position from user_ind_columns;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 125.Oracle查看数据段占空间大小<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> desc user_segments<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 126.Oracle查看表占空间大小<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> select segment_name,segment_type,bytes from user_segments where segment_type='TABLE';<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 127.安全删除USB<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rundll32.exe shell32.dll,Control_RunDLL hotplug.dll<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 128.打开SQL Server Management Studio<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> sqlwb %%1.sql<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 129.MySQL数据库导出备份<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> mysqldump -u %%1 -p %%2 %%3>%%4.sql<br style="word-wrap:break-word"> mysqldump --opt test > mysql.test //将数据库test导出到mysql.test文件,后面是一个文本文件<br style="word-wrap:break-word"> mysqldump -u root -p123456 --databases dbname > mysql.dbname //就是把数据库dbname导出到文件mysql.dbname中。<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 130.MySQL数据库数据导入<br style="word-wrap:break-word"> mysql -u %%1 -p %%2 %%3<%%4.sql<br style="word-wrap:break-word"> mysqlimport -u root -p123456 < mysql.dbname<br style="word-wrap:break-word"> 将文本数据导入数据库:<br style="word-wrap:break-word"> 文本数据的字段之间用tab键隔开<br style="word-wrap:break-word"> use test<br style="word-wrap:break-word"> load data local infile "文件名" into table 表名;<br style="word-wrap:break-word"> eg: load data local infile "D:/mysql.txt" into table mytable;<br style="word-wrap:break-word"> 导入.sql 文件命令<br style="word-wrap:break-word"> use database<br style="word-wrap:break-word"> source d:/mysql.sql;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 131.MySQL数据库检查<br style="word-wrap:break-word"> mysqlcheck -o %%3 -u %%1 -p %%2<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 132.MySQL数据表文件修复<br style="word-wrap:break-word"> myisamchk -B -o %%1.myd<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 1,查看数据库状态 及启动停止<br style="word-wrap:break-word"> /etc/init.d/mysqld status<br style="word-wrap:break-word"> /etc/init.d/mysqld start<br style="word-wrap:break-word"> /etc/init.d/mysqld stop<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 2,给用户配置初始密码123456:<br style="word-wrap:break-word"> mysqladmin -u root -password 123456<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 3,修改root用户密码为 abc123<br style="word-wrap:break-word"> mysqladmin -u root -p123456 password abc123<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 4,如果想去掉密码:<br style="word-wrap:break-word"> mysqladmin -u root -pabc123 password ""<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 5,root连接数据库有密码和无密码:<br style="word-wrap:break-word"> mysql -u root(-uroot) -p<br style="word-wrap:break-word"> mysql<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 6,增加用户 test1 密码 abc,让它可以在任何主机上登录,并对所有数据库有查询,插入,修改,删除的权限:<br style="word-wrap:break-word"> 格式: grant select on 数据库.* to 用户名@登录主机 identified by "密码"<br style="word-wrap:break-word"> grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 8,增加一个用户test2,让它只可以在localhost上登录,并可以对数据库mydb进行查询,插入,修改,删除的操作,<br style="word-wrap:break-word"> 这样用户即使使用知道test2的密码,他也无法从internet 上直接访问数据库,只能通过mysql主机上的web页面来访问。<br style="word-wrap:break-word"> grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";<br style="word-wrap:break-word"> grant select,insert,update,delete on mydb.* to test2@localhost identified by ""; 设置无密码<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 9,显示数据库列表:<br style="word-wrap:break-word"> show databases;<br style="word-wrap:break-word"> use mysql 打开库<br style="word-wrap:break-word"> show tables;<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 10,表的操作<br style="word-wrap:break-word"> describle 表名; 显示数据表的结构<br style="word-wrap:break-word"> create database 库名;<br style="word-wrap:break-word"> drop database 库名;<br style="word-wrap:break-word"> create table 表名(字段设定列表)<br style="word-wrap:break-word"> drop table 表名;<br style="word-wrap:break-word"> delete from 表名;清空表记录<br style="word-wrap:break-word"> select * from 表名; 显示表中的记录<br style="word-wrap:break-word"> insert into 表名 values(, ,)<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> alter table 表名 add column <字段名><字段选项><br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 133.检查端口占用<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> netstat -ano<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 134.Linux下检查Apache是否安装<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rpm -qa | grep httpd<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 135.Linux下启动Apache服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service httpd start<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 136.Linux下停止Apache服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service httpd stop<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 137.Linux下重新启动Apache服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service httpd restart<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 138.Linux下自动加载Apache 服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> chkconfig - level 3 httpd on<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 139.Linux下不自动加载Apache 服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> chkconfig - level 3 httpd off<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 140.Linux下检查VSFTP是否安装<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rpm -qa | grep vsftpd<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 141.Linux下启动VSFTP服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service vsftpd start<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 142.Linux下停止VSFTP服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service vsftpd stop<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 143.Linux下重新启动VSFTP服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service vsftpd restart<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 144.Linux下检查VSFTP是否被启动<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> pstree | grep vsftpd<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 145.Linux下检查Sendmail是否安装<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> rpm -qa | grep sendmail<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 146.Linux下启动Sendmail服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service sendmail start<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 147.Linux下停止Sendmail服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service sendma stop<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 148.Linux下重新启动Sendmail服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> service sendmail restart<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 149.Linux下自动加载Sendmail 服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> chkconfig - level 3 sendmail on<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 150.Linux下不自动加载Sendmail 服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> chkconfig - level 3 sendmail off<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 151.Linux下文本图形界面配置启动服务<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> ntsysv<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 152.以数组的方式删除文件夹<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 153.GCC批量编译<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find -type f \( -iname '*.c' -o -iname '*.cpp' \) -print |<br style="word-wrap:break-word"> while read filename<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     case "$filename" in<br style="word-wrap:break-word">     *.c)<br style="word-wrap:break-word">       gcc "$filename" -o "$(dirname "$filename")"/"$(basename "$filename" .c)"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.cpp)<br style="word-wrap:break-word">         gcc "$filename" -o "$(dirname "$filename")"/"$(basename "$filename" .cpp)"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     esac<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 154.批量赋予可执行权限<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find "$PWD" -type f \( -iname '*.sh' -o  -iname '*.csh' -o  -iname '*.ksh' -o -iname '*.pl' -o -iname '*.bin' -o -iname '*.run' -o -iname '*.bundle' -o -iname '*.rb' -o -iname '*.py' \) -print0 | xargs -0 chmod +x<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> for file in *.sh *.pl *.bin *.run *.bundle *.rb *.py<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [[ ! "$file" =~ \*.[A-Za-z]+ ]]; then<br style="word-wrap:break-word"> chmod +x "$(file)"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $(pwd) -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> for file in $path/*.sh $path/*.pl $path/*.bin $path/*.run $path/*.bundle $path/*.rb $path/*.py<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [[ ! "$file" =~ \*.[A-Za-z]+ ]]; then<br style="word-wrap:break-word"> chmod +x "$(path)/$(file)"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 155.批量执行<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find -type f \( -iname '*.sh' -o  -iname '*.csh' -o  -iname '*.ksh' -o -iname '*.pl' -o -iname '*.bin' -o -iname '*.run' -o -iname '*.bundle' -o -iname '*.bin' -o -iname '*.class' -o -iname '*.rpm' -o -iname '*.rb' -o -iname '*.py' -o -iname '*.jar' \) -print |<br style="word-wrap:break-word"> while read filename<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     case "$filename" in<br style="word-wrap:break-word">     *.sh | *.csh | *.ksh)<br style="word-wrap:break-word"> if [ ! "./""$(basename $filename)" = $0 ]; then<br style="word-wrap:break-word">         xterm -e "$filename"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.pl)<br style="word-wrap:break-word">         xterm -e perl "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.bin | *.run | *.bundle)<br style="word-wrap:break-word">         xterm -e "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.class)<br style="word-wrap:break-word">         xterm -e java "$(dirname "$filename")"/"$(basename "$filename" .class)"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.rpm)<br style="word-wrap:break-word">         xterm -e rpm -ivh "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.rb)<br style="word-wrap:break-word">         xterm -e ruby "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.py)<br style="word-wrap:break-word">         xterm -e python "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.jar)<br style="word-wrap:break-word">         xterm -e java -jar "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     esac<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find -maxdepth 1 -type f \( -iname '*.sh' -o -iname '*.pl' -o -iname '*.bin' -o -iname '*.run' -o -iname '*.bundle' -o -iname '*.bin' -o -iname '*.class' -o -iname '*.rpm' -o -iname '*.rb' -o -iname '*.py' -o -iname '*.jar' \) -print<br style="word-wrap:break-word"> while read file<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     case "${file##*.}" in<br style="word-wrap:break-word">         sh ) xterm -e """"$file"""";;<br style="word-wrap:break-word">         pl ) xterm -e perl """"$file"""";;<br style="word-wrap:break-word">         bin ) xterm -e """"$file"""";;<br style="word-wrap:break-word">         run ) xterm -e """"$file"""";;<br style="word-wrap:break-word">         bundle ) xterm -e """"$file"""";;<br style="word-wrap:break-word">         class ) xterm -e java """"${file%.*}"""";;<br style="word-wrap:break-word">         rpm ) xterm -e rpm -ivh """"$file"""";;<br style="word-wrap:break-word">         rb ) xterm -e ruby """"$file"""";;<br style="word-wrap:break-word">         py ) xterm -e python """"$file"""";;<br style="word-wrap:break-word">         jar ) xterm -e java -jar """"$file"""";;<br style="word-wrap:break-word">     esac<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 156.获取操作系统版本<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> uname -r<br style="word-wrap:break-word"> #uname -a<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 157.自身复制<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> cp $0 "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 158.GCC批量创建静态库<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find -type f \( -iname '*.c' -o -iname '*.cpp' \) -print |<br style="word-wrap:break-word"> while read filename<br style="word-wrap:break-word"> do<br style="word-wrap:break-word">     case "$filename" in<br style="word-wrap:break-word">     *.c)<br style="word-wrap:break-word">       g++  -c -o "$(dirname "$filename")"/"$(basename "$filename" .c)".o"" "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     *.cpp)<br style="word-wrap:break-word">       g++  -c -o "$(dirname "$filename")"/"$(basename "$filename" .cpp)".o"" "$filename"<br style="word-wrap:break-word">         ;;<br style="word-wrap:break-word">     esac<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $(pwd) -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> ar ru $path".a" $path"/*.o" && ranlib $path".a"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> find "$PWD" -type f \( -iname '*.o' \) -print0 | xargs -0 rm -if<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 159.Java批量打包EJB<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> find "$PWD" -type f \( -iname '*.java' \) -print0 | xargs -0 javac<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $(pwd) -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> jar -cvf "$(path".jar")" "$(path"/*.*")" && cp "$(path".jar")" "$(JBOSS_HOME"/server/default/deploy")"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> find "$PWD" -type f \( -iname '*.class' \) -print0 | xargs -0 rm -if<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 160.获取环境变量<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 161.dd<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> dd<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 162.显示只有小写字母的文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> ls -1|awk '/^[[:lower:]].*/'<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 163.Zip压缩目录中的所有文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> targetpath="%%2"<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $direc -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> mkdir -p "$targetpath/${path:${#direc}+1}"<br style="word-wrap:break-word"> for file in $path/*<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [ -f $file ]; then<br style="word-wrap:break-word"> zip -j "$targetpath/${path:${#direc}+1}/${file:${#path}+1}.zip" "$file"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 164.Zip解压缩目录中的所有文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> targetpath="%%2"<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $direc -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> mkdir -p "$targetpath/${path:${#direc}+1}"<br style="word-wrap:break-word"> unzip -x "$path/*.zip" -d "$targetpath/${path:${#direc}+1}"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 165.分布式复制文件夹<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> targetpath="%%2"<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $direc -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> mkdir -p "$targetpath/${path:${#direc}+1}"<br style="word-wrap:break-word"> rm -if "$targetpath/${path:${#direc}+1}/*.tmp"<br style="word-wrap:break-word"> for file in $path/*<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> if [ -f $file ]; then<br style="word-wrap:break-word"> cp "$file" "$targetpath/${path:${#direc}+1}/${file:${#path}+1}.tmp"<br style="word-wrap:break-word"> mv "$targetpath/${path:${#direc}+1}/${file:${#path}+1}.tmp" "$targetpath/${path:${#direc}+1}/${file:${#path}+1}"<br style="word-wrap:break-word"> fi<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 166.注册反注册组件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> regsvr32 "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 167.LZMA<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 168.CAB压缩文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 169.CAB解压缩文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 170.锁定屏幕<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> RUNDLL32.exe USER32,LockWorkStation<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 171.以其它用户的身份运行程序<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 172.添加系统用户<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> useradd "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 173.删除系统用户<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> userdel "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 174.添加用户组<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> groupadd -g 2000 "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 175.删除用户组<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> groupdel "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 176.赋予管理员权限<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 177.收回管理员权限<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 178.遍历目录产生删除文件的脚本<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 179.LZW压缩文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> z<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 180.LZW解压缩文件<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> z<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 181.递归赋予目录权限<br style="word-wrap:break-word"> #!/bin/bash<br style="word-wrap:break-word"> direc="%%1" #$(pwd)<br style="word-wrap:break-word"> OLDIFS=$IFS<br style="word-wrap:break-word"> IFS=:<br style="word-wrap:break-word"> for path in $( find $direc -type d -printf "%p$IFS")<br style="word-wrap:break-word"> do<br style="word-wrap:break-word"> chown -R root.root "$path"<br style="word-wrap:break-word"> done<br style="word-wrap:break-word"> IFS=$OLDIFS<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 182.卸载RPM包<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> rpm -e  "%%1"<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 183.删除源文件中的注释<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 184.设置目录下所有文件属性为可写<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 185.统计目录下所有文件的总共行数<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> cat * |wc<br style="word-wrap:break-word"> ls *|xargs wc -l<br style="word-wrap:break-word"> find ./ -name "*c" | xargs wc -l<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 186.删除自身<br style="word-wrap:break-word"> #!/bin/rm<br style="word-wrap:break-word"> exit 65<br style="word-wrap:break-word"> #rm $0<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 187.打开终端<br style="word-wrap:break-word"> #!/bin/bash -l<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 188.弹出光驱<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> eject<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 189.收回光驱<br style="word-wrap:break-word"> #!/bin/sh<br style="word-wrap:break-word"> eject -t<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 190.磁盘总空间计算<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 191.解析CSV文件<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 192.按行保存文件为数组<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> 193.MySQL执行SQL文件<br style="word-wrap:break-word"> mysqladmin -u %%1 -p%%2 < %%3.sql<br style="word-wrap:break-word"> <br style="word-wrap:break-word"> mysql -u %%1 -p%%2 -e "SOURCE %%3.sql"</span> </div> </div> <div class="Blog_con2_1 Blog_con3_2" style="word-wrap:break-word; margin-top:50px; position:relative; line-height:22px"> <div style="word-wrap:break-word; height:30px"> <div class="bdsharebuttonbox bdshare-button-style0-16" style="word-wrap:break-word; zoom:1; height:30px"> </div> </div> </div> </div> </div> </div> </div> </div> <!--PC和WAP自适应版--> <div id="SOHUCS" sid="1283099261327654912"></div> <script type="text/javascript" src="/views/front/js/chanyan.js"></script> <!-- 文章页-底部 动态广告位 --> <div class="youdao-fixed-ad" id="detail_ad_bottom"></div> </div> <div class="col-md-3"> <div class="row" id="ad"> <!-- 文章页-右侧1 动态广告位 --> <div id="right-1" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad"> <div class="youdao-fixed-ad" id="detail_ad_1"> </div> </div> <!-- 文章页-右侧2 动态广告位 --> <div id="right-2" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad"> <div class="youdao-fixed-ad" id="detail_ad_2"></div> </div> <!-- 文章页-右侧3 动态广告位 --> <div id="right-3" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad"> <div class="youdao-fixed-ad" id="detail_ad_3"></div> </div> </div> </div> </div> </div> </div> <div class="container"> <h4 class="pt20 mb15 mt0 border-top">你可能感兴趣的:(Linux,shell)</h4> <div id="paradigm-article-related"> <div class="recommend-post mb30"> <ul class="widget-links"> <li><a href="/article/1891770862227484672.htm" title="Linux 文件 1.4—文件描述符0 1 2(文件操作简述)" target="_blank">Linux 文件 1.4—文件描述符0 1 2(文件操作简述)</a> <span class="text-muted">胖胖的小肥猫</span> <a class="tag" taget="_blank" href="/search/Linux%E7%B3%BB%E7%BB%9F%E7%AC%94%E8%AE%B0/1.htm">Linux系统笔记</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/c%E8%AF%AD%E8%A8%80/1.htm">c语言</a> <div>文件描述符:关于这些:此处这里讲的十分的详细,清晰,膜拜大佬Linux中有这样一句话,万物皆可文件;1、对于内核而言,所有打开文件都由文件描述符引用,文件描述符是一个非负整数,当打开一个现存文件或者创建一个新文件时,内核向进程返回一个文件描述符,当读写一个文件时,用open()和creat()返回文件描述符标识该文件,将其作文参数,传递给read和write。而在Linux系统中,有默认文件描述符</div> </li> <li><a href="/article/1891765435225927680.htm" title="Linux基础03-指令篇之文件及其内容相关操作【入门级】" target="_blank">Linux基础03-指令篇之文件及其内容相关操作【入门级】</a> <span class="text-muted">kk努力学编程</span> <a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a> <div>Linux基础-文件操作内容概要本文主要介绍了在linux系统中如何通过终端指令对文件以及文件内容进行增删改查。同时上传了关于存储转换的小知识点。指令cat/less/more/head/tailcat:查看文件内容(少)执行权限:所有用户语法:cat[选项]文件选项-n:显示文件行号范例:cat/proc/cpuinfocat-n/proc/cpuinfomore:分页查看文件内容(多)执行权限</div> </li> <li><a href="/article/1891762031669866496.htm" title="初始java常见模板" target="_blank">初始java常见模板</a> <span class="text-muted">xx2534</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a> <div>Java是一种适用于多种应用程序的编程语言,支持各种不同类型和规模的开发项目,其模板也相对较多,以下是Java的一些常见模板:基础的HelloWorld模板:publicclassHelloWorld{publicstaticvoidmain(String[]args){System.out.println("Hello,World!");}}2.类和对象模板:publicclassPerson{</div> </li> <li><a href="/article/1891758626620633088.htm" title="Linux 查看文件的超强命令集合与实用技巧大揭秘" target="_blank">Linux 查看文件的超强命令集合与实用技巧大揭秘</a> <span class="text-muted">疯狂的键盘侠</span> <a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a> <div>Linux查看文件的超强命令集合与实用技巧大揭秘在Linux系统这片广阔天地里,查看文件内容是日常操作中最频繁的任务之一。无论是排查系统故障、分析日志,还是研读配置文档,掌握多样化的文件查看命令及技巧,都能让你如虎添翼,迅速定位所需信息。今天,就为大家呈上这份精心整理的Linux查看文件命令与技巧指南。一、基础查看命令cat:全称concatenate,简单直接,用于查看文本文件内容并输出到终端。</div> </li> <li><a href="/article/1891741977976827904.htm" title="Linux内存管理:深度解析与探索" target="_blank">Linux内存管理:深度解析与探索</a> <span class="text-muted">深度Linux</span> <a class="tag" taget="_blank" href="/search/Linux%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/1.htm">Linux内存管理</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/Linux%E5%86%85%E6%A0%B8/1.htm">Linux内核</a><a class="tag" taget="_blank" href="/search/%E5%86%85%E5%AD%98%E6%98%A0%E5%B0%84/1.htm">内存映射</a> <div>你是否想过,在Linux系统中,当你打开一个程序、浏览网页或者处理文件时,这些数据都存放在哪里呢?答案就是内存。Linux内存管理就像是一个超级大管家,它负责管理着系统中所有数据的“家”。这个“家”的空间有限,却要容纳各种各样的数据,而且要保证每个数据都能被快速准确地找到和使用。它需要智慧地分配房间(内存空间),合理地安排住户(进程),还要及时清理不再需要的杂物(回收内存)。今天,我们就一起深入了</div> </li> <li><a href="/article/1891733150015483904.htm" title="在linux 中搭建deepseek 做微调,硬件配置要求说明" target="_blank">在linux 中搭建deepseek 做微调,硬件配置要求说明</a> <span class="text-muted">慧香一格</span> <a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a><a class="tag" taget="_blank" href="/search/AI/1.htm">AI</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a><a class="tag" taget="_blank" href="/search/deepseek/1.htm">deepseek</a> <div>搭建可参考使用deepseek-CSDN博客官方网站:DeepSeekDeepSeek是一个基于深度学习的开源项目,旨在通过深度学习技术来提升搜索引擎的准确性和效率。如果你想在Linux系统上搭建DeepSeek,你可以遵循以下步骤。这里我将提供一个基本的指导,帮助你从零开始搭建一个基础的DeepSeek环境。1.安装依赖首先,确保你的Linux系统上安装了Python和pip。DeepSeek主</div> </li> <li><a href="/article/1891725447088107520.htm" title="M1 Mac双系统搭建qemu riscv linux仿真" target="_blank">M1 Mac双系统搭建qemu riscv linux仿真</a> <span class="text-muted">灰灰h</span> <a class="tag" taget="_blank" href="/search/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/1.htm">操作系统</a><a class="tag" taget="_blank" href="/search/%E7%BB%8F%E9%AA%8C%E5%88%86%E4%BA%AB/1.htm">经验分享</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/risc-v/1.htm">risc-v</a><a class="tag" taget="_blank" href="/search/macos/1.htm">macos</a> <div>前言实验需要riscv仿真,网上没有针对m1的配置教程,故在此整理下。本人用的m1macbookpro,系统12.3。参考到的链接:https://github.com/AsahiLinuxhttps://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.htmlhttps://zhuanlan.zhihu.com/p</div> </li> <li><a href="/article/1891721280340684800.htm" title="【Linux&Python】linux中通过源码方式安装python环境" target="_blank">【Linux&Python】linux中通过源码方式安装python环境</a> <span class="text-muted">atwdy</span> <a class="tag" taget="_blank" href="/search/%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE/1.htm">环境安装与配置</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a> <div>python环境安装直接看第二部分即可。文章目录1.背景2.python安装3.包环境复制1.背景部署一个线上任务时,相同的代码本地开发机正常产出数据,线上产出数据为0,排查到原因是:...File"/home/disk1/wangdeyong/venv/python3_shapely_new/lib/python3.9/site-packages/mcpack/pack.py",line15,i</div> </li> <li><a href="/article/1891705632654946304.htm" title="ERROR: could not inset ‘edd‘" target="_blank">ERROR: could not inset ‘edd‘</a> <span class="text-muted">lsw1990lsw</span> <a class="tag" taget="_blank" href="/search/centos/1.htm">centos</a> <div>1、进入该界面后键入"e"键进行编辑,vmlinuzinitrd.imginst.stage2=hd:LABEL=centOS\x207\x20x86_64rd.live.checkquiet把上述信息,修改为:vmlinuzinitrd.imglinuxddquiet2、按屏幕最下方提示按下“Ctrl+x”运行然后找到自己的u盘盘符,一般对应的是“centOS\x207\x20x86_64”,盘</div> </li> <li><a href="/article/1891696930774380544.htm" title="【组件-池式】线程池1-线程" target="_blank">【组件-池式】线程池1-线程</a> <span class="text-muted">好好学习++</span> <a class="tag" taget="_blank" href="/search/%E8%AF%BE%E7%A8%8B%E7%AC%94%E8%AE%B0/1.htm">课程笔记</a><a class="tag" taget="_blank" href="/search/%23/1.htm">#</a><a class="tag" taget="_blank" href="/search/C%2FC%2B%2B%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">C/C++服务器</a><a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/c%E8%AF%AD%E8%A8%80/1.htm">c语言</a> <div>声明:仅为个人学习总结,还请批判性查看,如有不同观点,欢迎交流。摘要介绍在Linux环境中,使用POSIXAPI和C++11进行线程开发的基本操作,包括线程的创建、退出,以及属性设置等。目录摘要1基本概念1.1线程函数1.2C++多线程开发方式2POSIX线程API2.1线程的创建2.2线程的属性2.2.1分离状态2.2.2调度策略2.3线程的退出2.3.1线程主动结束2.3.2pthread_k</div> </li> <li><a href="/article/1891672805674643456.htm" title="Linux:Supervisor进程管理" target="_blank">Linux:Supervisor进程管理</a> <span class="text-muted">m0_37559973</span> <a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a> <div>目录一、Supervisor介绍二、核心组件2.1supervisord2.2supervisorctl2.3WebServer三、安装Supervisor3.1安装要求3.2安装方式3.3修改WebServer端口(可选)3.4启动服务四、Supervisor常用命令4.1supervisord命令行选项4.2supervisorctl命令行选项五、监控服务5.1创建进程管理配置文件5.2重新加</div> </li> <li><a href="/article/1891672553525669888.htm" title="使用Docker部署Spark集群" target="_blank">使用Docker部署Spark集群</a> <span class="text-muted">小孩真笨</span> <a class="tag" taget="_blank" href="/search/%E5%B7%A5%E7%A8%8B%E5%BC%80%E5%8F%91%E6%8A%80%E6%9C%AF/1.htm">工程开发技术</a><a class="tag" taget="_blank" href="/search/Cloud/1.htm">Cloud</a><a class="tag" taget="_blank" href="/search/Data/1.htm">Data</a><a class="tag" taget="_blank" href="/search/Docker/1.htm">Docker</a><a class="tag" taget="_blank" href="/search/Spark/1.htm">Spark</a> <div>使用Docker部署Spark集群克隆包含启动脚本的git仓库启动Spark0.8.0集群并切换至SparkShell环境不带参数运行部署脚本*运行一些小的例子终止集群克隆包含启动脚本的git仓库*gitclone-bblogpostgit@github.com:amplab/docker-scripts.git当然,在这之前你必须已经配置了Github的SSH密钥认证,如果没有配置,会提示Per</div> </li> <li><a href="/article/1891668014617653248.htm" title="【Linux】 TCP短服务编写和守护进程" target="_blank">【Linux】 TCP短服务编写和守护进程</a> <span class="text-muted">杰瑞的猫^_^</span> <a class="tag" taget="_blank" href="/search/Linux/1.htm">Linux</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/tcp%2Fip/1.htm">tcp/ip</a><a class="tag" taget="_blank" href="/search/%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B/1.htm">守护进程</a><a class="tag" taget="_blank" href="/search/%E8%BF%9B%E7%A8%8B%E7%BB%84/1.htm">进程组</a> <div>文章目录TCP短服务编写流程进程组和会话和守护进程TCP短服务编写流程  TCP服务器是面向连接的,客户端在发送数据之前需要先与服务器建立连接。因此,TCP服务器需要能够监听客户端的连接请求。为了实现这一功能,需要将TCP服务器创建的套接字设置为监听状态,以便等待和处理客户端的连接请求。服务器在完成监听工作后,才算初始化完成。  客户端在创建套接字后,使用connect函数向服务器发起连接请求,而</div> </li> <li><a href="/article/1891651364589727744.htm" title="【Linux】【网络】Reactor模式" target="_blank">【Linux】【网络】Reactor模式</a> <span class="text-muted">钟离墨笺</span> <a class="tag" taget="_blank" href="/search/Linux/1.htm">Linux</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E7%BD%91%E7%BB%9C/1.htm">网络</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a> <div>【Linux】【网络】Reactor模式1.Reactor模式:Reactor模式是一种事件驱动的设计模式,同步I/O通常用于设置Reactor模式主线程(I/0处理单元,下同)只负责监听文件描述上是否有事件发生,有的话就立即将该事件通知工作线程(逻辑单元,下同)。除此之外,主线程不做任何其他实质性的工作。读写数据,接受新的连接,以及处理客户请求均在工作线程中完成。使用同步I/O模型(以epoll</div> </li> <li><a href="/article/1891650483089633280.htm" title="Linux 固定 IP 地址和网关" target="_blank">Linux 固定 IP 地址和网关</a> <span class="text-muted">法号:行颠</span> <a class="tag" taget="_blank" href="/search/Linux/1.htm">Linux</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a> <div>Linux固定IP地址和网关查看IPifconfigifconfigeth0ipaddripaddrshoweth0查看网关iprouteshowroute-nnetstat-rn设置固定IP//配置静态IP文件/etc/network/interfaces$vi/etc/network/interfacesautoeth0ifaceeth0inetstaticaddress192.168.0.2</div> </li> <li><a href="/article/1891648643631476736.htm" title="百万架构师第三十九课:RabbitMq:Linux安装RabbitMq|JavaGuide" target="_blank">百万架构师第三十九课:RabbitMq:Linux安装RabbitMq|JavaGuide</a> <span class="text-muted"></span> <a class="tag" taget="_blank" href="/search/%E5%90%8E%E7%AB%AF/1.htm">后端</a> <div>来源:https://javaguide.netRPM包安装RabbitMQRabbitMQ的安装非常简单,由于RabbitMQ依赖于Erlang,所以需要先安装Erlang,解决依赖关系后,就可以安装RabbitMQ了。注意,在安装Erlang前,需要先安装socat安装socat[root@nogeek]#yum-yinstallsocat下载RPM包RabbitMQ:http://www.r</div> </li> <li><a href="/article/1891636853182885888.htm" title="1、Android概述" target="_blank">1、Android概述</a> <span class="text-muted">守望178</span> <a class="tag" taget="_blank" href="/search/Android/1.htm">Android</a> <div>安卓(Android)是一种基于Linux的自由及开放源代码的操作系统。主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。Android操作系统最初由AndyRubin开发,主要支持手机。2005年8月由Google收购注资。2007年11月,Google与84家硬件制造商、软件开发商及电信营运商组建开放手机联盟共同研发改良Android系统。随后Google以</div> </li> <li><a href="/article/1891628147342897152.htm" title="Linux内核中的双向链表list_head" target="_blank">Linux内核中的双向链表list_head</a> <span class="text-muted">ioriwc</span> <a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E9%93%BE%E8%A1%A8/1.htm">链表</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a> <div>双向链表在Linux内核中使用非常多,它是内核各种队列、栈的基础,相关的结构定义和函数均在include/linux/list.h中定义,下面介绍下其原理及使用方法。1、结构体定义structlist_head{structlist_head*next,*prev;};双向链表结构体很简单,有prev和next两个指针,分别指向链表的前一节点和后一节点。这里专门讲下空链表,空链表指链表的prev和</div> </li> <li><a href="/article/1891626632213491712.htm" title="android-为手机设置全局代理" target="_blank">android-为手机设置全局代理</a> <span class="text-muted">carden_coder</span> <a class="tag" taget="_blank" href="/search/agent/1.htm">agent</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a> <div>有这么一个需求,需要给手机设置全局代理。百度到的结果都是设置后,如果需要清除代理的话,需要重启手机,这里使用的方式是不需要重启的方式后实现方式如下:设置代理:String[]strings={"settingsputglobalhttp_proxy"+ip+":"+port};ShellUtils.CommandResultcommandResult2=ShellUtils.execCmd(str</div> </li> <li><a href="/article/1891626127848435712.htm" title="Alpine 安装 应用错误 ERROR: unable to select packages" target="_blank">Alpine 安装 应用错误 ERROR: unable to select packages</a> <span class="text-muted">seojava</span> <a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a> <div>/#apkaddcurlfetchhttps://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/x86_64/APKINDEX.tar.gzWARNING:updatingandopeninghttps://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/:Nosuchfileor</div> </li> <li><a href="/article/1891613138260914176.htm" title="mysql 如何查看建表语句" target="_blank">mysql 如何查看建表语句</a> <span class="text-muted">艾斯比的日常</span> <a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a><a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a><a class="tag" taget="_blank" href="/search/database/1.htm">database</a> <div>由于公司都是使用linux跳板机连接mysql,而某个项目又没有测试环境,于是只能通过跳板机查看某张表的详细信息.具体语句如下这里以查看ups_auth_info表为例#\G表示以垂直形式查看结果showcreatetableups_auth_info\G;总结:showcreatetablexxx\G;语句虽然简单,但是自己如果不注重积累,那么在使用mysql命令时,就不得不现场查询sql语法,</div> </li> <li><a href="/article/1891605791962624000.htm" title="提示-bash: telnet: command not found的解决方法" target="_blank">提示-bash: telnet: command not found的解决方法</a> <span class="text-muted">廖俊才</span> <a class="tag" taget="_blank" href="/search/Linux/1.htm">Linux</a><a class="tag" taget="_blank" href="/search/CentOS/1.htm">CentOS</a> <div>Linuxcentos运行telnet命令,出现下面的错误提示:[root@localhost~]#telnet127.0.0.1-bash:telnet:commandnotfound解决方法:安装telnet服务centos、ubuntu安装telnet命令的方法.yumlisttelnet*列出telnet相关的安装包yuminstalltelnet-server安装telnet服务yumi</div> </li> <li><a href="/article/1891605665542107136.htm" title="clang编译代码报错:`_start': (.text+0x24): undefined reference to `main'" target="_blank">clang编译代码报错:`_start': (.text+0x24): undefined reference to `main'</a> <span class="text-muted">PandaMohist</span> <a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/javascript/1.htm">javascript</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a> <div>1.说明使用clang++10.1编译报错:/usr/bin/ld:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crt1.o:infunction`_start':(.text+0x24):undefinedreferenceto`main'clang-10:error:linkercommandfailedwithexitc</div> </li> <li><a href="/article/1891603142257209344.htm" title="(.text+0x1b): undefined reference to `main‘" target="_blank">(.text+0x1b): undefined reference to `main‘</a> <span class="text-muted">༺࿈梦༒缘࿈༻</span> <a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a> <div>使用vscodeLinuxg++编译出现/usr/bin/ld:/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o:infunction`_start':(.text+0x1b):undefinedreferenceto`main'collect2:error:ldreturned1exitstatusmake:**</div> </li> <li><a href="/article/1891567567097622528.htm" title="Linux下CMake 3.28.2版本针对ARM64架构的预编译安装包" target="_blank">Linux下CMake 3.28.2版本针对ARM64架构的预编译安装包</a> <span class="text-muted">安检</span> <div>本文还有配套的精品资源,点击获取简介:CMake是一个跨平台的自动化构建系统,通过配置文件简化了项目构建过程,并能够生成适应不同操作系统和编译器环境的构建工具。版本3.28.2针对Linux系统和aarch64架构预编译,适用于64位ARM处理器。该版本包括了所有必要的可执行文件、库、模块和文档。解压后,通过简单几步即可安装并开始使用CMake来构建项目。1.CMake简介和特性CMake简介CM</div> </li> <li><a href="/article/1891563280082726912.htm" title="【MongoDB】MongoDb的“not master and slaveok=false”错误及解决方法" target="_blank">【MongoDB】MongoDb的“not master and slaveok=false”错误及解决方法</a> <span class="text-muted">weixin_30900589</span> <a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a><a class="tag" taget="_blank" href="/search/shell/1.htm">shell</a> <div>链接mongodb报错如下2016-03-14T16:26:00.912+0800EQUERY[thread1]Error:listDatabasesfailed:{"ok":0,"errmsg":"notmasterandslaveOk=false","code":13435}:_getErrorWithCode@src/mongo/shell/utils.js:23:13Mongo.proto</div> </li> <li><a href="/article/1891563280896421888.htm" title="【MongoDB】MongoDb的“not master and slaveok=false”错误及解决方法 mongo连接从库出现问题..." target="_blank">【MongoDB】MongoDb的“not master and slaveok=false”错误及解决方法 mongo连接从库出现问题...</a> <span class="text-muted">weixin_33782386</span> <a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a><a class="tag" taget="_blank" href="/search/shell/1.htm">shell</a><a class="tag" taget="_blank" href="/search/php/1.htm">php</a> <div>链接mongodb报错如下2016-03-14T16:26:00.912+0800EQUERY[thread1]Error:listDatabasesfailed:{"ok":0,"errmsg":"notmasterandslaveOk=false","code":13435}:_getErrorWithCode@src/mongo/shell/utils.js:23:13Mongo.proto</div> </li> <li><a href="/article/1891562899537719296.htm" title="学习笔记之debian的thonny开发(尚未验证)--从stm32裸机到linux嵌入式系统" target="_blank">学习笔记之debian的thonny开发(尚未验证)--从stm32裸机到linux嵌入式系统</a> <span class="text-muted">sjh2100</span> <a class="tag" taget="_blank" href="/search/%E5%B5%8C%E5%85%A5%E5%BC%8F%E7%A1%AC%E4%BB%B6/1.htm">嵌入式硬件</a><a class="tag" taget="_blank" href="/search/%E7%A1%AC%E4%BB%B6%E5%B7%A5%E7%A8%8B/1.htm">硬件工程</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/stm32/1.htm">stm32</a><a class="tag" taget="_blank" href="/search/debian/1.htm">debian</a> <div>这应该算stm32裸机用户转linux嵌入式系统的入门学习笔记。【鲁班猫】39-vnc远程桌面连接鲁班猫_哔哩哔哩_bilibili本集的鲁班猫的视频介绍中,没有清晰明确指出需要linux开发板接入网络,接入网络可以使用有线网口或者wifi路由,有些提示信息是来自开发板还是win电脑屏幕并不是很明确。stm32开发需要win+keil+stlink+开发板。linux嵌入式系统应用开发需要:lin</div> </li> <li><a href="/article/1891549650175979520.htm" title="Android N(全志平台A40i)添加adb登录密码" target="_blank">Android N(全志平台A40i)添加adb登录密码</a> <span class="text-muted">阿姨打太极</span> <a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/adb/1.htm">adb</a> <div>需求:在adbshell登录终端时加入鉴权密码,鉴权开关可配置且密码可修改问题分析:见下文AndroidN:adb及adbd源码分析解决方案:思路:pc上终端输入adbshell命令后,实际上是adbd守护进程fork出的子进程来执行/bin/sh,adbd监听usb/tcp输入执行命令,并通过socket将结果回显到pc。那么我们解决该问题的方法就是在执行/bin/sh之前加入我们的校验脚本。1</div> </li> <li><a href="/article/1891549145018200064.htm" title="DeepSeek 满血版的部署方案" target="_blank">DeepSeek 满血版的部署方案</a> <span class="text-muted">rockmelodies</span> <a class="tag" taget="_blank" href="/search/deepseek/1.htm">deepseek</a><a class="tag" taget="_blank" href="/search/%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD/1.htm">人工智能</a><a class="tag" taget="_blank" href="/search/deepseek/1.htm">deepseek</a> <div>1.环境准备确保你的服务器或本地开发环境满足以下要求:操作系统:Linux(推荐Ubuntu20.04LTS或CentOS7)内存:至少16GBCPU:至少4核硬盘:至少50GB可用空间网络:稳定的互联网连接2.安装依赖安装必要的软件包和依赖项:#更新系统包sudoapt-getupdatesudoapt-getupgrade-y#安装必要的软件包sudoapt-getinstall-ybuild</div> </li> <li><a href="/article/94.htm" title="PHP,安卓,UI,java,linux视频教程合集" target="_blank">PHP,安卓,UI,java,linux视频教程合集</a> <span class="text-muted">cocos2d-x小菜</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/UI/1.htm">UI</a><a class="tag" taget="_blank" href="/search/PHP/1.htm">PHP</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a> <div>╔-----------------------------------╗┆                           </div> </li> <li><a href="/article/221.htm" title="各表中的列名必须唯一。在表 'dbo.XXX' 中多次指定了列名 'XXX'。" target="_blank">各表中的列名必须唯一。在表 'dbo.XXX' 中多次指定了列名 'XXX'。</a> <span class="text-muted">bozch</span> <a class="tag" taget="_blank" href="/search/.net/1.htm">.net</a><a class="tag" taget="_blank" href="/search/.net+mvc/1.htm">.net mvc</a> <div>在.net mvc5中,在执行某一操作的时候,出现了如下错误:       各表中的列名必须唯一。在表 'dbo.XXX' 中多次指定了列名 'XXX'。 经查询当前的操作与错误内容无关,经过对错误信息的排查发现,事故出现在数据库迁移上。 回想过去: 在迁移之前已经对数据库进行了添加字段操作,再次进行迁移插入XXX字段的时候,就会提示如上错误。  &</div> </li> <li><a href="/article/348.htm" title="Java 对象大小的计算" target="_blank">Java 对象大小的计算</a> <span class="text-muted">e200702084</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a> <div>                          Java对象的大小 如何计算一个对象的大小呢?    </div> </li> <li><a href="/article/475.htm" title="Mybatis Spring" target="_blank">Mybatis Spring</a> <span class="text-muted">171815164</span> <a class="tag" taget="_blank" href="/search/mybatis/1.htm">mybatis</a> <div>ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); CustomerService userService = (CustomerService) ac.getBean("customerService"); Customer cust</div> </li> <li><a href="/article/602.htm" title="JVM 不稳定参数" target="_blank">JVM 不稳定参数</a> <span class="text-muted">g21121</span> <a class="tag" taget="_blank" href="/search/jvm/1.htm">jvm</a> <div>        -XX 参数被称为不稳定参数,之所以这么叫是因为此类参数的设置很容易引起JVM 性能上的差异,使JVM 存在极大的不稳定性。当然这是在非合理设置的前提下,如果此类参数设置合理讲大大提高JVM 的性能及稳定性。        可以说“不稳定参数”</div> </li> <li><a href="/article/729.htm" title="用户自动登录网站" target="_blank">用户自动登录网站</a> <span class="text-muted">永夜-极光</span> <a class="tag" taget="_blank" href="/search/%E7%94%A8%E6%88%B7/1.htm">用户</a> <div>1.目标:实现用户登录后,再次登录就自动登录,无需用户名和密码 2.思路:将用户的信息保存为cookie            每次用户访问网站,通过filter拦截所有请求,在filter中读取所有的cookie,如果找到了保存登录信息的cookie,那么在cookie中读取登录信息,然后直接</div> </li> <li><a href="/article/856.htm" title="centos7 安装后失去win7的引导记录" target="_blank">centos7 安装后失去win7的引导记录</a> <span class="text-muted">程序员是怎么炼成的</span> <a class="tag" taget="_blank" href="/search/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/1.htm">操作系统</a> <div>1.使用root身份(必须)打开 /boot/grub2/grub.cfg 2.找到 ### BEGIN /etc/grub.d/30_os-prober ###   在后面添加    menuentry "Windows 7 (loader) (on /dev/sda1)" { </div> </li> <li><a href="/article/983.htm" title="Oracle 10g 官方中文安装帮助文档以及Oracle官方中文教程文档下载" target="_blank">Oracle 10g 官方中文安装帮助文档以及Oracle官方中文教程文档下载</a> <span class="text-muted">aijuans</span> <a class="tag" taget="_blank" href="/search/oracle/1.htm">oracle</a> <div>Oracle 10g 官方中文安装帮助文档下载:http://download.csdn.net/tag/Oracle%E4%B8%AD%E6%96%87API%EF%BC%8COracle%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3%EF%BC%8Coracle%E5%AD%A6%E4%B9%A0%E6%96%87%E6%A1%A3 Oracle 10g 官方中文教程</div> </li> <li><a href="/article/1110.htm" title="JavaEE开源快速开发平台G4Studio_V3.2发布了" target="_blank">JavaEE开源快速开发平台G4Studio_V3.2发布了</a> <span class="text-muted">無為子</span> <a class="tag" taget="_blank" href="/search/AOP/1.htm">AOP</a><a class="tag" taget="_blank" href="/search/oracle/1.htm">oracle</a><a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a><a class="tag" taget="_blank" href="/search/javaee/1.htm">javaee</a><a class="tag" taget="_blank" href="/search/G4Studio/1.htm">G4Studio</a> <div>  我非常高兴地宣布,今天我们最新的JavaEE开源快速开发平台G4Studio_V3.2版本已经正式发布。大家可以通过如下地址下载。   访问G4Studio网站 http://www.g4it.org   G4Studio_V3.2版本变更日志 功能新增 (1).新增了系统右下角滑出提示窗口功能。 (2).新增了文件资源的Zip压缩和解压缩</div> </li> <li><a href="/article/1237.htm" title="Oracle常用的单行函数应用技巧总结" target="_blank">Oracle常用的单行函数应用技巧总结</a> <span class="text-muted">百合不是茶</span> <a class="tag" taget="_blank" href="/search/%E6%97%A5%E6%9C%9F%E5%87%BD%E6%95%B0/1.htm">日期函数</a><a class="tag" taget="_blank" href="/search/%E8%BD%AC%E6%8D%A2%E5%87%BD%E6%95%B0%28%E6%A0%B8%E5%BF%83%29/1.htm">转换函数(核心)</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E5%AD%97%E5%87%BD%E6%95%B0/1.htm">数字函数</a><a class="tag" taget="_blank" href="/search/%E9%80%9A%E7%94%A8%E5%87%BD%E6%95%B0%28%E6%A0%B8%E5%BF%83%29/1.htm">通用函数(核心)</a><a class="tag" taget="_blank" href="/search/%E5%AD%97%E7%AC%A6%E5%87%BD%E6%95%B0/1.htm">字符函数</a> <div>单行函数;   字符函数,数字函数,日期函数,转换函数(核心),通用函数(核心) 一:字符函数: .UPPER(字符串) 将字符串转为大写 .LOWER (字符串) 将字符串转为小写 .INITCAP(字符串) 将首字母大写 .LENGTH (字符串) 字符串的长度 .REPLACE(字符串,'A','_') 将字符串字符A转换成_ </div> </li> <li><a href="/article/1364.htm" title="Mockito异常测试实例" target="_blank">Mockito异常测试实例</a> <span class="text-muted">bijian1013</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95/1.htm">单元测试</a><a class="tag" taget="_blank" href="/search/mockito/1.htm">mockito</a> <div>Mockito异常测试实例: package com.bijian.study; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.junit.Assert; import org.junit.Test; import org.mockito.</div> </li> <li><a href="/article/1491.htm" title="GA与量子恒道统计" target="_blank">GA与量子恒道统计</a> <span class="text-muted">Bill_chen</span> <a class="tag" taget="_blank" href="/search/JavaScript/1.htm">JavaScript</a><a class="tag" taget="_blank" href="/search/%E6%B5%8F%E8%A7%88%E5%99%A8/1.htm">浏览器</a><a class="tag" taget="_blank" href="/search/%E7%99%BE%E5%BA%A6/1.htm">百度</a><a class="tag" taget="_blank" href="/search/Google/1.htm">Google</a><a class="tag" taget="_blank" href="/search/%E9%98%B2%E7%81%AB%E5%A2%99/1.htm">防火墙</a> <div>前一阵子,统计**网址时,Google Analytics(GA) 和量子恒道统计(也称量子统计),数据有较大的偏差,仔细找相关资料研究了下,总结如下:   为何GA和量子网站统计(量子统计前身为雅虎统计)结果不同? 首先:没有一种网站统计工具能保证百分之百的准确出现该问题可能有以下几个原因:(1)不同的统计分析系统的算法机制不同;(2)统计代码放置的位置和前后</div> </li> <li><a href="/article/1618.htm" title="【Linux命令三】Top命令" target="_blank">【Linux命令三】Top命令</a> <span class="text-muted">bit1129</span> <a class="tag" taget="_blank" href="/search/linux%E5%91%BD%E4%BB%A4/1.htm">linux命令</a> <div>Linux的Top命令类似于Windows的任务管理器,可以查看当前系统的运行情况,包括CPU、内存的使用情况等。如下是一个Top命令的执行结果:     top - 21:22:04 up 1 day, 23:49, 1 user, load average: 1.10, 1.66, 1.99 Tasks: 202 total, 4 running, 198 sl</div> </li> <li><a href="/article/1745.htm" title="spring四种依赖注入方式" target="_blank">spring四种依赖注入方式</a> <span class="text-muted">白糖_</span> <a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a> <div>  平常的java开发中,程序员在某个类中需要依赖其它类的方法,则通常是new一个依赖类再调用类实例的方法,这种开发存在的问题是new的类实例不好统一管理,spring提出了依赖注入的思想,即依赖类不由程序员实例化,而是通过spring容器帮我们new指定实例并且将实例注入到需要该对象的类中。依赖注入的另一种说法是“控制反转”,通俗的理解是:平常我们new一个实例,这个实例的控制权是我</div> </li> <li><a href="/article/1872.htm" title="angular.injector" target="_blank">angular.injector</a> <span class="text-muted">boyitech</span> <a class="tag" taget="_blank" href="/search/AngularJS/1.htm">AngularJS</a><a class="tag" taget="_blank" href="/search/AngularJS+API/1.htm">AngularJS API</a> <div>angular.injector   描述: 创建一个injector对象, 调用injector对象的方法可以获得angular的service, 或者用来做依赖注入.   使用方法: angular.injector(modules, [strictDi])   参数详解: Param Type Details mod</div> </li> <li><a href="/article/1999.htm" title="java-同步访问一个数组Integer[10],生产者不断地往数组放入整数1000,数组满时等待;消费者不断地将数组里面的数置零,数组空时等待" target="_blank">java-同步访问一个数组Integer[10],生产者不断地往数组放入整数1000,数组满时等待;消费者不断地将数组里面的数置零,数组空时等待</a> <span class="text-muted">bylijinnan</span> <a class="tag" taget="_blank" href="/search/Integer/1.htm">Integer</a> <div> public class PC { /** * 题目:生产者-消费者。 * 同步访问一个数组Integer[10],生产者不断地往数组放入整数1000,数组满时等待;消费者不断地将数组里面的数置零,数组空时等待。 */ private static final Integer[] val=new Integer[10]; private static</div> </li> <li><a href="/article/2126.htm" title="使用Struts2.2.1配置" target="_blank">使用Struts2.2.1配置</a> <span class="text-muted">Chen.H</span> <a class="tag" taget="_blank" href="/search/apache/1.htm">apache</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/Web/1.htm">Web</a><a class="tag" taget="_blank" href="/search/xml/1.htm">xml</a><a class="tag" taget="_blank" href="/search/struts/1.htm">struts</a> <div>Struts2.2.1 需要如下 jar包: commons-fileupload-1.2.1.jar commons-io-1.3.2.jar commons-logging-1.0.4.jar freemarker-2.3.16.jar javassist-3.7.ga.jar ognl-3.0.jar spring.jar struts2-core-2.2.1.jar struts2-sp</div> </li> <li><a href="/article/2253.htm" title="[职业与教育]青春之歌" target="_blank">[职业与教育]青春之歌</a> <span class="text-muted">comsci</span> <a class="tag" taget="_blank" href="/search/%E6%95%99%E8%82%B2/1.htm">教育</a> <div>        每个人都有自己的青春之歌............但是我要说的却不是青春...        大家如果在自己的职业生涯没有给自己以后创业留一点点机会,仅仅凭学历和人脉关系,是难以在竞争激烈的市场中生存下去的....   &nbs</div> </li> <li><a href="/article/2380.htm" title="oracle连接(join)中使用using关键字" target="_blank">oracle连接(join)中使用using关键字</a> <span class="text-muted">daizj</span> <a class="tag" taget="_blank" href="/search/JOIN/1.htm">JOIN</a><a class="tag" taget="_blank" href="/search/oracle/1.htm">oracle</a><a class="tag" taget="_blank" href="/search/sql/1.htm">sql</a><a class="tag" taget="_blank" href="/search/using/1.htm">using</a> <div>在oracle连接(join)中使用using关键字 34. View the Exhibit and examine the structure of the ORDERS and ORDER_ITEMS tables. Evaluate the following SQL statement: SELECT oi.order_id, product_id, order_date FRO</div> </li> <li><a href="/article/2507.htm" title="NIO示例" target="_blank">NIO示例</a> <span class="text-muted">daysinsun</span> <a class="tag" taget="_blank" href="/search/nio/1.htm">nio</a> <div>NIO服务端代码: public class NIOServer { private Selector selector; public void startServer(int port) throws IOException { ServerSocketChannel serverChannel = ServerSocketChannel.open(</div> </li> <li><a href="/article/2634.htm" title="C语言学习homework1" target="_blank">C语言学习homework1</a> <span class="text-muted">dcj3sjt126com</span> <a class="tag" taget="_blank" href="/search/c/1.htm">c</a><a class="tag" taget="_blank" href="/search/homework/1.htm">homework</a> <div>0、 课堂练习做完 1、使用sizeof计算出你所知道的所有的类型占用的空间。 int x; sizeof(x);   sizeof(int);   # include <stdio.h> int main(void) { int x1; char x2; double x3; float x4; printf(&quo</div> </li> <li><a href="/article/2761.htm" title="select in order by , mysql排序" target="_blank">select in order by , mysql排序</a> <span class="text-muted">dcj3sjt126com</span> <a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a> <div>If i select like this: SELECT id FROM users WHERE id IN(3,4,8,1); This by default will select users in this order 1,3,4,8, I would like to select them in the same order that i put IN() values so: </div> </li> <li><a href="/article/2888.htm" title="页面校验-新建项目" target="_blank">页面校验-新建项目</a> <span class="text-muted">fanxiaolong</span> <a class="tag" taget="_blank" href="/search/%E9%A1%B5%E9%9D%A2%E6%A0%A1%E9%AA%8C/1.htm">页面校验</a> <div>$(document).ready( function() { var flag = true; $('#changeform').submit(function() { var projectScValNull = true; var s =""; var parent_id = $("#parent_id").v</div> </li> <li><a href="/article/3015.htm" title="Ehcache(02)——ehcache.xml简介" target="_blank">Ehcache(02)——ehcache.xml简介</a> <span class="text-muted">234390216</span> <a class="tag" taget="_blank" href="/search/ehcache/1.htm">ehcache</a><a class="tag" taget="_blank" href="/search/ehcache.xml/1.htm">ehcache.xml</a><a class="tag" taget="_blank" href="/search/%E7%AE%80%E4%BB%8B/1.htm">简介</a> <div>ehcache.xml简介          ehcache.xml文件是用来定义Ehcache的配置信息的,更准确的来说它是定义CacheManager的配置信息的。根据之前我们在《Ehcache简介》一文中对CacheManager的介绍我们知道一切Ehcache的应用都是从CacheManager开始的。在不指定配置信</div> </li> <li><a href="/article/3142.htm" title="junit 4.11中三个新功能" target="_blank">junit 4.11中三个新功能</a> <span class="text-muted">jackyrong</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a> <div>junit 4.11中两个新增的功能,首先是注解中可以参数化,比如 import static org.junit.Assert.assertEquals; import java.util.Arrays; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runn</div> </li> <li><a href="/article/3269.htm" title="国外程序员爱用苹果Mac电脑的10大理由" target="_blank">国外程序员爱用苹果Mac电脑的10大理由</a> <span class="text-muted">php教程分享</span> <a class="tag" taget="_blank" href="/search/windows/1.htm">windows</a><a class="tag" taget="_blank" href="/search/PHP/1.htm">PHP</a><a class="tag" taget="_blank" href="/search/unix/1.htm">unix</a><a class="tag" taget="_blank" href="/search/Microsoft/1.htm">Microsoft</a><a class="tag" taget="_blank" href="/search/perl/1.htm">perl</a> <div>Mac 在国外很受欢迎,尤其是在 设计/web开发/IT 人员圈子里。普通用户喜欢 Mac 可以理解,毕竟 Mac 设计美观,简单好用,没有病毒。那么为什么专业人士也对 Mac 情有独钟呢?从个人使用经验来看我想有下面几个原因: 1、Mac OS X 是基于 Unix 的 这一点太重要了,尤其是对开发人员,至少对于我来说很重要,这意味着Unix 下一堆好用的工具都可以随手捡到。如果你是个 wi</div> </li> <li><a href="/article/3396.htm" title="位运算、异或的实际应用" target="_blank">位运算、异或的实际应用</a> <span class="text-muted">wenjinglian</span> <a class="tag" taget="_blank" href="/search/%E4%BD%8D%E8%BF%90%E7%AE%97/1.htm">位运算</a> <div>一. 位操作基础,用一张表描述位操作符的应用规则并详细解释。       二. 常用位操作小技巧,有判断奇偶、交换两数、变换符号、求绝对值。       三. 位操作与空间压缩,针对筛素数进行空间压缩。    &n</div> </li> <li><a href="/article/3523.htm" title="weblogic部署项目出现的一些问题(持续补充中……)" target="_blank">weblogic部署项目出现的一些问题(持续补充中……)</a> <span class="text-muted">Everyday都不同</span> <a class="tag" taget="_blank" href="/search/weblogic%E9%83%A8%E7%BD%B2%E5%A4%B1%E8%B4%A5/1.htm">weblogic部署失败</a> <div>好吧,weblogic的问题确实……   问题一: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [zip:E:/weblogic/user_projects/domains/base_domain/serve</div> </li> <li><a href="/article/3650.htm" title="tomcat7性能调优(01)" target="_blank">tomcat7性能调优(01)</a> <span class="text-muted">toknowme</span> <a class="tag" taget="_blank" href="/search/tomcat7/1.htm">tomcat7</a> <div>    Tomcat优化: 1、最大连接数最大线程等设置 <Connector port="8082" protocol="HTTP/1.1"                useBodyEncodingForURI="t</div> </li> <li><a href="/article/3777.htm" title="PO VO DAO DTO BO TO概念与区别" target="_blank">PO VO DAO DTO BO TO概念与区别</a> <span class="text-muted">xp9802</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/DAO/1.htm">DAO</a><a class="tag" taget="_blank" href="/search/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/1.htm">设计模式</a><a class="tag" taget="_blank" href="/search/bean/1.htm">bean</a><a class="tag" taget="_blank" href="/search/%E9%A2%86%E5%9F%9F%E6%A8%A1%E5%9E%8B/1.htm">领域模型</a> <div>O/R Mapping 是 Object Relational Mapping(对象关系映射)的缩写。通俗点讲,就是将对象与关系数据库绑定,用对象来表示关系数据。在O/R Mapping的世界里,有两个基本的也是重要的东东需要了解,即VO,PO。 它们的关系应该是相互独立的,一个VO可以只是PO的部分,也可以是多个PO构成,同样也可以等同于一个PO(指的是他们的属性)。这样,PO独立出来,数据持</div> </li> </ul> </div> </div> </div> <div> <div class="container"> <div class="indexes"> <strong>按字母分类:</strong> <a href="/tags/A/1.htm" target="_blank">A</a><a href="/tags/B/1.htm" target="_blank">B</a><a href="/tags/C/1.htm" target="_blank">C</a><a href="/tags/D/1.htm" target="_blank">D</a><a href="/tags/E/1.htm" target="_blank">E</a><a href="/tags/F/1.htm" target="_blank">F</a><a href="/tags/G/1.htm" target="_blank">G</a><a href="/tags/H/1.htm" target="_blank">H</a><a href="/tags/I/1.htm" target="_blank">I</a><a href="/tags/J/1.htm" target="_blank">J</a><a href="/tags/K/1.htm" target="_blank">K</a><a href="/tags/L/1.htm" target="_blank">L</a><a href="/tags/M/1.htm" target="_blank">M</a><a href="/tags/N/1.htm" target="_blank">N</a><a href="/tags/O/1.htm" target="_blank">O</a><a href="/tags/P/1.htm" target="_blank">P</a><a href="/tags/Q/1.htm" target="_blank">Q</a><a href="/tags/R/1.htm" target="_blank">R</a><a href="/tags/S/1.htm" target="_blank">S</a><a href="/tags/T/1.htm" target="_blank">T</a><a href="/tags/U/1.htm" target="_blank">U</a><a href="/tags/V/1.htm" target="_blank">V</a><a href="/tags/W/1.htm" target="_blank">W</a><a href="/tags/X/1.htm" target="_blank">X</a><a href="/tags/Y/1.htm" target="_blank">Y</a><a href="/tags/Z/1.htm" target="_blank">Z</a><a href="/tags/0/1.htm" target="_blank">其他</a> </div> </div> </div> <footer id="footer" class="mb30 mt30"> <div class="container"> <div class="footBglm"> <a target="_blank" href="/">首页</a> - <a target="_blank" href="/custom/about.htm">关于我们</a> - <a target="_blank" href="/search/Java/1.htm">站内搜索</a> - <a target="_blank" href="/sitemap.txt">Sitemap</a> - <a target="_blank" href="/custom/delete.htm">侵权投诉</a> </div> <div class="copyright">版权所有 IT知识库 CopyRight © 2000-2050 E-COM-NET.COM , All Rights Reserved. <!-- <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">京ICP备09083238号</a><br>--> </div> </div> </footer> <!-- 代码高亮 --> <script type="text/javascript" src="/static/syntaxhighlighter/scripts/shCore.js"></script> <script type="text/javascript" src="/static/syntaxhighlighter/scripts/shLegacy.js"></script> <script type="text/javascript" src="/static/syntaxhighlighter/scripts/shAutoloader.js"></script> <link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/styles/shCoreDefault.css"/> <script type="text/javascript" src="/static/syntaxhighlighter/src/my_start_1.js"></script> </body> </html>