LinuxSir.Org  
| 网站首页 | 论坛帮助 |

欢迎来到LinuxSir.Org!
您还未登录,请登录后查看论坛,或者点击论坛上方的注册链接注册新账号。


发表新主题 回复
置顶的主题 精华主题  
主题工具
旧 03-10-01, 02:39 第 61 帖
devel
 
devel 的头像
 
 
已封禁  
  注册日期: Sep 2003
  我的住址: 自由的世界 !
  帖子: 1,472
  精华: 6
 

一个用mplayer听音乐的简单脚本。
特别感谢原创者: devel
-------------------------------------------------
#!/usr/local/bin/bash
#date:2003/10/1
mount /mnt/d 2>/dev/null #suppress error message
#touch /mnt/d/media/test0 2>/dev/null 。
#mv -rf `find / -name *.mp3` /mnt/d/media/test0
a=`pwd`
cd /mnt/d/media/good/
while true
do
echo "input music name: (will exit if you enter e ! )"
read name
if [ $name = "e" ] ; then echo "The process will exit !";cd $a;exit 0;fi
r=`echo $name|rev|cut -c1-2|rev`
m=`echo $name|rev|cut -c1-3|rev`
if [[ $r = "rm" || $m = "mp3" ]];then
if [ -r $name ];then
mplayer $name
echo "music already played complete !";sleep 3
else echo "Good bye ! Dear This music can not read ! You can play next time !"
fi
else echo "Can not support this type !";fi
done
#祝大家国庆节快乐!!
-----------------------------------------------
谢谢大家的帮助!有什么bug就指出。

此帖于 03-10-18 10:04 被 KornLee 编辑.
  devel 当前离线   回复时引用此帖
旧 03-10-03, 18:11 第 62 帖
KornLee
 
 
 
★☆★☆★☆★  
  注册日期: Nov 2002
  我的住址: LinuxWorld
  帖子: 6,960
  精华: 61
 

标题: latex2pdf的脚本


作者:alphatan
由于本人学LaTeX也不久,所以有些功能可能没想到,欢迎大家对程序修改,适应各自的需要。本脚本已可以处理索引了,以后将会不断更新。
代码:
#!/bin/bash # # "latex2pdf.sh" is a script written in bash to make processing latex # file easier. # Copyright (C) 2003 alphatan<alphatan@263.net> version 0.51 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # target=${1%.tex} action=$2 declare -f dvi errorMsg ldvi lpdf lpdfmx lps lview pdf pdfmx ps view function errorMsg() { echo -e " Usage: ${0##*/} <filename> [action] " >&2 echo -e " <filename> : the tex file with '.tex' extension. " echo -e " This could not be ignored." echo -e " [action] : the 'action' you wish to operate on the '.tex' file" echo -e " dvi : process to 'dvi' output" echo -e " ps : process to 'ps' output" echo -e " pdf : process to 'pdf' output with 'dvipdf' command " echo -e " pdfmx : process to 'pdf' output with 'dvipdfmx' command " echo -e " view : view the '<filename>.pdf' with 'acroread' \n" echo -e " The action type above could put an 'l' precede it. eg. 'ldvi' " echo -e " it will call the corresponding process and do a cleaning course by " echo -e " the end. " echo -e " If the 'action' is ignored, it is refer to 'lview', it would " echo -e " cause 'lpdfmx' and 'cleaning course', and view the '.pdf' output " echo -e " with 'acroread'" } if [ ! -e ${target}.tex ]; then echo -e "ERROR!!: ${target}.tex does not exist! " >&2 errorMsg exit 1 fi function dvi() { if latex ${target}.tex ; then if [ -e ${target}.idx ] ; then if makeindex ${target}.idx ; then if latex ${target}.tex ; then return 0; else return 1 fi else return 1 fi else return 0 fi else return 1 fi } function ps() { if dvi ; then if dvips ${target}.dvi ; then return 0; else return 1 fi else return 1 fi } function pdf() { if dvi ; then if dvipdf ${target}.dvi ; then return 0; else return 1 fi else return 1 fi } function pdfmx() { if dvi ; then if dvipdfmx ${target}.dvi ; then return 0; else return 1 fi else return 1 fi } function view() { if [ -e ${target}.pdf ] ; then acroread ${target}.pdf else return 1 fi } function cleanFiles() { echo "Cleaning process caught ... " unset i; for i in aux dvi idx ilg ind lof log lot pdf ps ; do if [ ! $i = $1 ]; then if [ -e ${target}.$i ]; then rm -f ${target}.$i fi fi done unset i; } function ldvi() { if dvi ; then cleanFiles dvi else return 1 fi } function lps() { if ps ; then cleanFiles ps else return 1 fi } function lpdf() { if pdf ; then cleanFiles pdf else return 1 fi } function lpdfmx() { if pdfmx ; then cleanFiles pdf else return 1 fi } function lview() { if lpdfmx ; then if acroread ${target}.pdf ; then cleanFiles pdf return 0 else return 1 fi else return 1 fi } case $action in dvi ) eval $action ;; ps ) eval $action ;; pdf ) eval $action ;; pdfmx ) eval $action ;; view ) eval $action ;; ldvi ) eval $action ;; lps ) eval $action ;; lpdfmx ) eval $action ;; lview ) eval $action ;; '' ) eval lpdfmx ;; * ) echo -e "Error Action type! " >&2 errorMsg exit 1 ;; esac
  KornLee 当前离线   回复时引用此帖
旧 03-10-18, 02:36 第 63 帖
alphatan
 
 
 
注册会员  
  注册日期: Aug 2003
  帖子: 18
  精华: 1
 

标题: del-and-recover 0.52 to Linux


特别感谢作者: alphatan
发信人: alphatan ([`a:lfa:ta2n]), 信区: LinuxApp
标 题: Re: del-and-recover 0.52 (1-3 del)
发信站: BBS 水木清华站 (Sat Oct 18 04:44:43 2003), 转信


写了两天,终于写完了,基本可实现如win下的“回收站”功能。
del: 删除东西用的。
del {路径}
路径允许通配符,允许多个路径,允许相对与绝对路径混用
lstrash: 看自己的垃圾筒内有什么。当然,一如“回收站”,如果你自己硬塞进去
的东西它是记录不了的。
lstrash [-n]
显示垃圾筒里的东西,参数-n用于显示其在记录文件中的行号。
undel: 恢复用。
undel {-ln LINENUMBER | -tn TRASHNAME | -sp SOURCEPATH}
-ln LINUENUMBER LINENUMBER为lstrash -n显示的行号
-tn TRASHNAME TRASHNAME,文件在垃圾筒内的名字,记录文件的第一列。
-sp SOURCEPATH SOURCEPATH,删除前的原文件的绝对路径--能力有限,不能确定唯一的绝对跟径……--也就是记录文件的第二加第三列形成的路径。

【 在 alphatan ([`a:lfa:ta2n]) 的大作中提到: 】
: #!/bin/bash
: #
: # "delset" is a set of scripts written in bash to simulate the win
: # version of del-and-recover to Linux. This is the content of 'del'
: # Copyright (C) 2003 alphatan<alphatan@263.net> version 0.52
: #
: # This program is free software; you can redistribute it and/or modify
: # it under the terms of the GNU General Public License as published by
: # the Free Software Foundation; either version 2 of the License, or
: # (at your option) any later version.
: #
: ...................

--
Learning is to improve, but not to prove.


※ 来源:·BBS 水木清华站 smth.org·[FROM: 218.19.45.30]

发信人: alphatan ([`a:lfa:ta2n]), 信区: LinuxApp
标 题: del-and-recover 0.52 (1-3 del)
发信站: BBS 水木清华站 (Sat Oct 18 04:41:29 2003), 转信
代码:
#!/bin/bash # # "delset" is a set of scripts written in bash to simulate the win # version of del-and-recover to Linux. This is the content of 'del' # Copyright (C) 2003 alphatan<alphatan@263.net> version 0.52 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Your *preparation* comes here declare -i NumberOfsourceFiles declare -f cleanTrash trashIsFull processFile appendRecordANDremoveFile declare -a sourceFiles # 对@, 1, 2, 3...之类的变量越早操作越好。 sourceNumber=${#@} # 以下对IFS的操作比较简单,不会引起异常。 tempIFS=$IFS IFS=$';' sourceFiles=( $@ ) IFS=$tempIFS unset tempIFS NumberOfsourceFiles=${#sourceFiles[@]} # function definition begin function appendRecordANDremoveFile() { declare baseName dirName extName dirName="$1" baseName="$2" if [ "${baseName#*.}" = "${baseName}" ]; then extName="" else extName=".${baseName#*.}" fi # 这里可以加个测试,看.Trashdbm的第一栏中有没有跟filenameInTrash一样的 # 文件名,如果有的话就再提一次随机数。 # 我这里没设的原因是,既然人家叫得说是随机数,应该相同率起码小于 # 1,000,000吧,而每次都在这测试的话,又是读文件,又是调用其它程序的, # 浪费太多资源,所以省了这步。要求高的自己写上吧。 filenameInTrash="$(echo $RANDOM)$extName" if [ -e ${HOME}/.Trash/.Trashdbm ] ; then if [ -w ${HOME}/.Trash/.Trashdbm ] ; then if mv "$dirName/$baseName" "${HOME}/.Trash/$filenameInTrash" ; then echo -e "$filenameInTrash;$dirName;$baseName" >>$HOME/.Trash/.Trashdbm else return 1 fi else echo -e "I can NOT write the Record file!" >&2 return 1 fi elif [ -w ${HOME}/.Trash/ ] ; then if mv "$dirName/$baseName" "${HOME}/.Trash/$filenameInTrash" ; then echo -e "$filenameInTrash;$dirName;$baseName" >>$HOME/.Trash/.Trashdbm else return 1 fi else echo -e "I can NOT write the Record file!" >&2 return 1 fi } # processFile不可以有return--否则会停了大while了。其返回值为离开本函数前最后执行的命令。 function processFile() { declare i baseName dirName declare -i j=0 while (( $j < ${NumberOfsourceFiles} )) ; do i="${sourceFiles[$j]}" # 虽然多了个变量,但程序看起来舒服一些。 if [ "${i#/}" = "${i}" ]; then # 测试参数给出的是绝对路径还是相对路径 i="$(pwd)/$i" # 形成绝对路径 本为相对路径 dirName=$(dirname "$i") baseName=$(basename "$i") if [ -e "$i" ] && [ -w "${dirName}" ]; then # 测试是否可删 appendRecordANDremoveFile "$dirName" "$baseName" else echo -e "!!ERROR!!\n\"$i\" NOT-exist or NOT-writable!" >&2 fi else i="$i" # 形成绝对路径 -- 符合规划书 dirName=$(dirname "$i") baseName=$(basename "$i") if [ -e "$i" ] && [ -w "${dirName}" ]; then # 测试是否可删 appendRecordANDremoveFile "$dirName" "$baseName" else echo -e "!!ERROR!!\n\"$i\" NOT-exist or NOT-writable!" >&2 fi fi let j++ done } function cleanTrash() { if [ -x ${HOME}/.Trash ] && [ -w ${HOME}/.Trash ] ; then rm -rf ${HOME}/.Trash/* echo "" >${HOME}/.Trash/.Trashdbm return 0 else echo -e "!!ERROR!!\nI could not open your TRASH directory!\n Cleaning course FAILED!" >&2 return 1 fi } function trashIsFull() { declare cleanResponse trashVolumn=$(du -sm ~/.Trash |awk '{print $1}') if [ $trashVolumn -ge 501 ]; then echo -n "!!ERROR!!\nYour Trash is out of 500M!! Clean ALL?(yes, or else)" >&2 read cleanResponse cleanResponse=$(echo $cleanResponse |tr [A-Z] [a-z]) if [ "$cleanResponse" = 'yes' ] ; then if cleanTrash ; then if processFile ; then return 0 else return 1 fi else return 1 fi else echo -e "I had NOT done ANY cleaning, Your Trash is still FULL!!" >&2 return 0 fi else if processFile ; then return 0 else return 1 fi fi } # function definition end # function *main* comes here trashIsFull




--
Learning is to improve, but not to prove.


※ 来源:·BBS 水木清华站 smth.org·[FROM: 218.19.45.30]


发信人: alphatan ([`a:lfa:ta2n]), 信区: LinuxApp
标 题: del-and-recover 0.52 (2-3 lstrash)
发信站: BBS 水木清华站 (Sat Oct 18 04:42:11 2003), 转信
代码:
#!/bin/bash # # "delset" is a set of scripts written in bash to simulate the win # version of del-and-recover to Linux. This is the content of 'lstrash' # Copyright (C) 2003 alphatan<alphatan@263.net> version 0.52 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # 这里不使用getopts,只有(只允许)一个选项,没必要用那个。 declare showLineNumber="$1" if [ ! -r ${HOME}/.Trash/.Trashdbm ]; then exit 1 fi if [ "$showLineNumber" = '-n' ] ; then awk -F\; 'BEGIN{counter=1}{print counter" : " $1" => "$2"/"$3; counter++;}' ${HOME}/.Trash/.Trashdbm elif [ "$showLineNumber" = '' ] ; then awk -F\; '{print $1" => "$2"/"$3}' ${HOME}/.Trash/.Trashdbm elif [ "$showLineNumber" = '--help' ] || [ "$showLineNumber" = '-h' ] ; then echo -e " Usage: ${0##*/} [-n]" >&2 else echo -e "!!ERROR!!\nunknown Argument: \"$showLineNumber\" \n Usage: ${0##*/} [-n]" >&2 fi
--
Learning is to improve, but not to prove.


※ 来源:·BBS 水木清华站 smth.org·[FROM: 218.19.45.30]


发信人: alphatan ([`a:lfa:ta2n]), 信区: LinuxApp
标 题: del-and-recover 0.52 (3-3 undel)
发信站: BBS 水木清华站 (Sat Oct 18 04:42:57 2003), 转信
代码:
#!/bin/bash # # "delset" is a set of scripts written in bash to simulate the win # version of del-and-recover to Linux. This is the content of 'undel' # Copyright (C) 2003 alphatan<alphatan@263.net> version 0.52 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Your *preparation* comes here declare whatDoYouWant whichFile declare -f checkArgument cleanRecord undelWithLN undelWithTN undelWithSP whatDoYouWant="$1" whichFile="$2" # function definition begin function checkArgument() { if [ ! -z "$whichFile" ]; then if [ "$whatDoYouWant" = '-ln' ]; then # 测试如果以'-ln'开头,其参是否为完全整数构成。 if [ -z "$(echo $whichFile |sed -e 's/[0-9]//g')" ]; then if [ $whichFile -gt 0 ]; then undelWithLN $whichFile else echo -e "!!ERROR!!\nYour LINENUMBER exceed legal range." >&2 return 1 fi else return 1 fi elif [ "$whatDoYouWant" = '-tn' ]; then undelWithTN "$whichFile" elif [ "$whatDoYouWant" = '-sp' ]; then undelWithSP "$whichFile" else # 无任何参数,则默认出错。 echo -e "!!ERROR!!\nunknown Argument: \"$whatDoYouWant\" \n Usage: ${0##*/} {-ln LINENUMBER | -tn TRASHNAME | -sp SOURCEPATH}" >&2 return 1 fi else # 没了第二个参数。 echo -e "!!ERROR!!\nArgument required. \n Usage: ${0##*/} {-ln LINENUMBER | -tn TRASHNAME | -sp SOURCEPATH}" >&2 return 1 fi } function cleanRecord() { declare lineNumber=$1 if sed -e "${lineNumber}d" ${HOME}/.Trash/.Trashdbm >/tmp/trash.tmp ; then if mv --force /tmp/trash.tmp ${HOME}/.Trash/.Trashdbm ; then rm --force /tmp/trash.tmp # 如果成功返回'成功'。 else return 1 fi else return 1 fi } function undelWithLN() { declare -i lineNumber declare -a operateFile lineNumber="$1" if [ ! -w ${HOME}/.Trash/.Trashdbm ]; then echo -e "!!ERROR!!\nI didn't have write permittion to ${HOME}/.Trash/.Trashdbm" >&2 return 1 fi # 暂时改变IFS,为了把文件中的记录分隔 #echo "BREAK POINT 1" >&2 declare tempIFS=$IFS IFS=$';' operateFile=( $(sed -ne "${lineNumber}p" ${HOME}/.Trash/.Trashdbm) ) IFS=$tempIFS unset tempIFS #echo "BREAK POINT 2" >&2 if [ ${#operateFile[@]} -eq 0 ]; then echo -e "!!ERROR!!\nYour LINENUMBER exceed the record range." >&2 return 1 fi # 测原目录是否存在并可写 if [ ! -w "${HOME}/.Trash/${operateFile[0]}" ] ; then echo -e "!!ERROR!!\n\"${HOME}/.Trash/${operateFile[0]}\" seems NOT writable or exist. " >&2 # 删除记录 cleanRecord $lineNumber # 上面不写入程序是因为mount与umount的关系,如flashram,所以可能有些记录要自己手动删除记录 return 1 # 返回出错 纵使删除记录成功与否,以后的改进版本会有不同的返回码 elif [ ! -w "${operateFile[1]}" ]; then echo -e "!!ERROR!!\n\"${operateFile[1]}\" seems NOT writable or exist. " >&2 # 删除记录 cleanRecord $lineNumber return 1 # 返回出错 else if mv "${HOME}/.Trash/${operateFile[0]}" "${operateFile[1]}/${operateFile[2]}" ; then echo -e "Recovery: ${HOME}/.Trash/${operateFile[0]} => ${operateFile[1]}/${operateFile[2]}" >&2 # 删除记录 cleanRecord $lineNumber # 返回代码看删除记录的返回码 else return 1 fi fi } function undelWithTN() { declare fileNameInTrash=$1 declare -i lineNumber lineNumber=$(grep -n "$fileNameInTrash;" ${HOME}/.Trash/.Trashdbm | awk -F\: '{print $1}') if [ $lineNumber -gt 0 ]; then undelWithLN $lineNumber else echo -e "!!ERROR!!\n\"$fileNameInTrash\" is NOT found in ${HOME}/.Trash/.Trashdbm\n You might recover it yourself..." >&2 return 1 fi } function undelWithSP() { declare fileNameInSourcePath dirName baseName declare -i lineNumber fileNameInSourcePath="$1" dirName=$(dirname "$fileNameInSourcePath") baseName=$(basename "$fileNameInSourcePath") lineNumber=$(grep -n ";$dirName;$baseName" ${HOME}/.Trash/.Trashdbm | awk -F\: '{print $1}') if [ $lineNumber -gt 0 ]; then undelWithLN $lineNumber else echo -e "!!ERROR!!\n\"$fileNameInSourcePath\" is NOT found in ${HOME}/.Trash/.Trashdbm" echo -e "If your file really exist, You might recover it yourself..." >&2 return 1 fi } # function definition end # function *main* comes here checkArgument

--
Learning is to improve, but not to prove.


※ 来源:·BBS 水木清华站 smth.org·[FROM: 218.19.45.30]



此帖于 03-10-18 10:02 被 KornLee 编辑.
  alphatan 当前离线   回复时引用此帖
旧 03-10-21, 17:22 第 64 帖
KornLee
 
 
 
★☆★☆★☆★  
  注册日期: Nov 2002
  我的住址: LinuxWorld
  帖子: 6,960
  精华: 61
 

标题: shell game:俄罗斯方块


特别感谢作者:飞灰橙
转自: www.chinaunix.net

运行于GNU bash, version 2.05a.0(1)-release (i686-pc-linux-gnu)

代码:
#!/bin/bash # Tetris Game # 10.21.2003 xhchen<xhchen@winbond.com.tw> #color definition cRed=1 cGreen=2 cYellow=3 cBlue=4 cFuchsia=5 cCyan=6 cWhite=7 colorTable=($cRed $cGreen $cYellow $cBlue $cFuchsia $cCyan $cWhite) #size & position iLeft=3 iTop=2 ((iTrayLeft = iLeft + 2)) ((iTrayTop = iTop + 1)) ((iTrayWidth = 10)) ((iTrayHeight = 15)) #style definition cBorder=$cGreen cScore=$cFuchsia cScoreValue=$cCyan #control signal sigRotate=25 sigLeft=26 sigRight=27 sigDown=28 sigAllDown=29 sigExit=30 box0=(0 0 0 1 1 0 1 1) box1=(0 2 1 2 2 2 3 2 1 0 1 1 1 2 1 3) box2=(0 0 0 1 1 1 1 2 0 1 1 0 1 1 2 0) box3=(0 1 0 2 1 0 1 1 0 0 1 0 1 1 2 1) box4=(0 1 0 2 1 1 2 1 1 0 1 1 1 2 2 2 0 1 1 1 2 0 2 1 0 0 1 0 1 1 1 2) box5=(0 1 1 1 2 1 2 2 1 0 1 1 1 2 2 0 0 0 0 1 1 1 2 1 0 2 1 0 1 1 1 2) box6=(0 1 1 1 1 2 2 1 1 0 1 1 1 2 2 1 0 1 1 0 1 1 2 1 0 1 1 0 1 1 1 2) box=(${box0[@]} ${box1[@]} ${box2[@]} ${box3[@]} ${box4[@]} ${box5[@]} ${box6[@]}) countBox=(1 2 2 2 4 4 4) offsetBox=(0 1 3 5 7 11 15) iScoreEachLevel=50 #be greater than 7 #Runtime data sig=0 iScore=0 iLevel=0 boxNew=() #new box cBoxNew=0 #new box color iBoxNewType=0 #new box type iBoxNewRotate=0 #new box rotate degree boxCur=() #current box cBoxCur=0 #current box color iBoxCurType=0 #current box type iBoxCurRotate=0 #current box rotate degree boxCurX=-1 #current X position boxCurY=-1 #current Y position iMap=() for ((i = 0; i < iTrayHeight * iTrayWidth; i++)); do iMap[$i]=-1; done function RunAsKeyReceiver() { local pidDisplayer key aKey sig cESC sTTY pidDisplayer=$1 aKey=(0 0 0) cESC=`echo -ne "\33"` cSpace=`echo -ne "\40"` sTTY=`stty -g` trap "MyExit;" INT TERM trap "MyExitNoSub;" $sigExit echo -ne "\33[?25l" while [[ 1 ]] do read -s -n 1 key aKey[0]=${aKey[1]} aKey[1]=${aKey[2]} aKey[2]=$key sig=0 if [[ $key == $cESC && ${aKey[1]} == $cESC ]] then MyExit elif [[ ${aKey[0]} == $cESC && ${aKey[1]} == "[" ]] then if [[ $key == "A" ]]; then sig=$sigRotate elif [[ $key == "B" ]]; then sig=$sigDown elif [[ $key == "D" ]]; then sig=$sigLeft elif [[ $key == "C" ]]; then sig=$sigRight fi elif [[ $key == "W" || $key == "w" ]]; then sig=$sigRotate elif [[ $key == "S" || $key == "s" ]]; then sig=$sigDown elif [[ $key == "A" || $key == "a" ]]; then sig=$sigLeft elif [[ $key == "D" || $key == "d" ]]; then sig=$sigRight elif [[ "[$key]" == "[]" ]]; then sig=$sigAllDown elif [[ $key == "Q" || $key == "q" ]] then MyExit fi if [[ $sig != 0 ]] then kill -$sig $pidDisplayer fi done } function MyExitNoSub() { local y stty $sTTY ((y = iTop + iTrayHeight + 4)) echo -e "\33[?25h\33[${y};0H" exit } function MyExit() { kill -$sigExit $pidDisplayer MyExitNoSub } function RunAsDisplayer() { local sigThis InitDraw trap "sig=$sigRotate;" $sigRotate trap "sig=$sigLeft;" $sigLeft trap "sig=$sigRight;" $sigRight trap "sig=$sigDown;" $sigDown trap "sig=$sigAllDown;" $sigAllDown trap "ShowExit;" $sigExit while [[ 1 ]] do for ((i = 0; i < 21 - iLevel; i++)) do usleep 20000 sigThis=$sig sig=0 if ((sigThis == sigRotate)); then BoxRotate; elif ((sigThis == sigLeft)); then BoxLeft; elif ((sigThis == sigRight)); then BoxRight; elif ((sigThis == sigDown)); then BoxDown; elif ((sigThis == sigAllDown)); then BoxAllDown; fi done #kill -$sigDown $$ BoxDown done } function BoxMove() { local j i x y xTest yTest yTest=$1 xTest=$2 for ((j = 0; j < 8; j += 2)) do ((i = j + 1)) ((y = ${boxCur[$j]} + yTest)) ((x = ${boxCur[$i]} + xTest)) if (( y < 0 || y >= iTrayHeight || x < 0 || x >= iTrayWidth)) then return 1 fi if ((${iMap[y * iTrayWidth + x]} != -1 )) then return 1 fi done return 0; } function Box2Map() { local j i x y xp yp line for ((j = 0; j < 8; j += 2)) do ((i = j + 1)) ((y = ${boxCur[$j]} + boxCurY)) ((x = ${boxCur[$i]} + boxCurX)) ((i = y * iTrayWidth + x)) iMap[$i]=$cBoxCur done line=0 for ((j = iTrayWidth * iTrayHeight; j > 0; j -= iTrayWidth)) do for ((i = j - iTrayWidth; i < j; i++)) do if ((${iMap[$i]} == -1)); then break; fi done if ((i < j)); then continue; fi ((line++)) for ((i = j - 1; i >= iTrayWidth; i--)) do ((x = i - iTrayWidth)) iMap[$i]=${iMap[$x]} done for ((i = 0; i < iTrayWidth; i++)) do iMap[$i]=-1 done done if ((line == 0)); then return; fi ((x = iLeft + iTrayWidth * 2 + 7)) ((y = iTop + 11)) ((iScore += line * 2 - 1)) echo -ne "\33[1m\33[3${cScoreValue}m\33[${y};${x}H${iScore} " if ((iScore % iScoreEachLevel < line * 2 - 1)) then if ((iLevel < 20)) then ((iLevel++)) ((y = iTop + 14)) echo -ne "\33[3${cScoreValue}m\33[${y};${x}H${iLevel} " fi fi echo -ne "\33[0m" for ((y = 0; y < iTrayHeight; y++)) do ((yp = y + iTrayTop + 1)) ((xp = iTrayLeft + 1)) ((i = y * iTrayWidth)) echo -ne "\33[${yp};${xp}H" for ((x = 0; x < iTrayWidth; x++)) do ((j = i + x)) if ((${iMap[$j]} == -1)) then echo -ne " " else echo -ne "\33[1m\33[3${iMap[$j]}m\33[4${iMap[$j]}m[]\33[0m" fi done done } function BoxDown() { local y s ((y = boxCurY + 1)) if BoxMove $y $boxCurX then s="`DrawCurBox 0`" ((boxCurY = y)) s="$s`DrawCurBox 1`" echo -ne $s else Box2Map RandomBox fi } function BoxLeft() { local x s ((x = boxCurX - 1)) if BoxMove $boxCurY $x then s=`DrawCurBox 0` ((boxCurX = x)) s=$s`DrawCurBox 1` echo -ne $s fi } function BoxRight() { local x s ((x = boxCurX + 1)) if BoxMove $boxCurY $x then s=`DrawCurBox 0` ((boxCurX = x)) s=$s`DrawCurBox 1` echo -ne $s fi } function BoxAllDown() { local k j i x y iDown s iDown=$iTrayHeight for ((j = 0; j < 8; j += 2)) do ((i = j + 1)) ((y = ${boxCur[$j]} + boxCurY)) ((x = ${boxCur[$i]} + boxCurX)) for ((k = y + 1; k < iTrayHeight; k++)) do ((i = k * iTrayWidth + x)) if (( ${iMap[$i]} != -1)); then break; fi done ((k -= y + 1)) if (( $iDown > $k )); then iDown=$k; fi done s=`DrawCurBox 0` ((boxCurY += iDown)) s=$s`DrawCurBox 1` echo -ne $s Box2Map RandomBox } function BoxRotate() { local iCount iTestRotate boxTest j i s iCount=${countBox[$iBoxCurType]} ((iTestRotate = iBoxCurRotate + 1)) if ((iTestRotate >= iCount)) then ((iTestRotate = 0)) fi for ((j = 0, i = (${offsetBox[$iBoxCurType]} + $iTestRotate) * 8; j < 8; j++, i++)) do boxTest[$j]=${boxCur[$j]} boxCur[$j]=${box[$i]} done if BoxMove $boxCurY $boxCurX then for ((j = 0; j < 8; j++)) do boxCur[$j]=${boxTest[$j]} done s=`DrawCurBox 0` for ((j = 0, i = (${offsetBox[$iBoxCurType]} + $iTestRotate) * 8; j < 8; j++, i++)) do boxCur[$j]=${box[$i]} done s=$s`DrawCurBox 1` echo -ne $s iBoxCurRotate=$iTestRotate else for ((j = 0; j < 8; j++)) do boxCur[$j]=${boxTest[$j]} done fi } function DrawCurBox() { local i j t bDraw sBox s bDraw=$1 s="" if (( bDraw == 0 )) then sBox="\40\40" else sBox="[]" s=$s"\33[1m\33[3${cBoxCur}m\33[4${cBoxCur}m" fi for ((j = 0; j < 8; j += 2)) do ((i = iTrayTop + 1 + ${boxCur[$j]} + boxCurY)) ((t = iTrayLeft + 1 + 2 * (boxCurX + ${boxCur[$j + 1]}))) s=$s"\33[${i};${t}H${sBox}" done s=$s"\33[0m" echo -n $s } function RandomBox() { local i j t #change current box iBoxCurType=${iBoxNewType} iBoxCurRotate=${iBoxNewRotate} cBoxCur=${cBoxNew} for ((j = 0; j < ${#boxNew[@]}; j++)) do boxCur[$j]=${boxNew[$j]} done if (( ${#boxCur[@]} == 8 )) then #calculate current box's starting position for ((j = 0, t = 4; j < 8; j += 2)) do if ((${boxCur[$j]} < t)); then t=${boxCur[$j]}; fi done ((boxCurY = -t)) for ((j = 1, i = -4, t = 20; j < 8; j += 2)) do if ((${boxCur[$j]} > i)); then i=${boxCur[$j]}; fi if ((${boxCur[$j]} < t)); then t=${boxCur[$j]}; fi done ((boxCurX = (iTrayWidth - 1 - i - t) / 2)) echo -ne `DrawCurBox 1` if ! BoxMove $boxCurY $boxCurX then kill -$sigExit ${PPID} ShowExit fi fi #clear old box for ((j = 0; j < 4; j++)) do ((i = iTop + 1 + j)) ((t = iLeft + 2 * iTrayWidth + 7)) echo -ne "\33[${i};${t}H " done #get a random new box ((iBoxNewType = RANDOM % ${#offsetBox[@]})) ((iBoxNewRotate = RANDOM % ${countBox[$iBoxNewType]})) for ((j = 0, i = (${offsetBox[$iBoxNewType]} + $iBoxNewRotate) * 8; j < 8; j++, i++)) do boxNew[$j]=${box[$i]}; done ((cBoxNew = ${colorTable[RANDOM % ${#colorTable[@]}]})) #display new box echo -ne "\33[1m\33[3${cBoxNew}m\33[4${cBoxNew}m" for ((j = 0; j < 8; j += 2)) do ((i = iTop + 1 + ${boxNew[$j]})) ((t = iLeft + 2 * iTrayWidth + 7 + 2 * ${boxNew[$j + 1]})) echo -ne "\33[${i};${t}H[]" done echo -ne "\33[0m" } function InitDraw() { clear RandomBox RandomBox local i t1 t2 t3 #draw border echo -ne "\33[1m" echo -ne "\33[3${cBorder}m\33[4${cBorder}m" ((t2 = iLeft + 1)) ((t3 = iLeft + iTrayWidth * 2 + 3)) for ((i = 0; i < iTrayHeight; i++)) do ((t1 = i + iTop + 2)) echo -ne "\33[${t1};${t2}H||" echo -ne "\33[${t1};${t3}H||" done ((t2 = iTop + iTrayHeight + 2)) for ((i = 0; i < iTrayWidth + 2; i++)) do ((t1 = i * 2 + iLeft + 1)) echo -ne "\33[${iTrayTop};${t1}H==" echo -ne "\33[${t2};${t1}H==" done echo -ne "\33[0m" #draw score & level prompt echo -ne "\33[1m" ((t1 = iLeft + iTrayWidth * 2 + 7)) ((t2 = iTop + 10)) echo -ne "\33[3${cScore}m\33[${t2};${t1}HScore" ((t2 = iTop + 11)) echo -ne "\33[3${cScoreValue}m\33[${t2};${t1}H${iScore}" ((t2 = iTop + 13)) echo -ne "\33[3${cScore}m\33[${t2};${t1}HLevel" ((t2 = iTop + 14)) echo -ne "\33[3${cScoreValue}m\33[${t2};${t1}H${iLevel}" echo -ne "\33[0m" } function ShowExit() { local y ((y = iTrayHeight + iTrayTop + 3)) echo -e "\33[${y};0HGameOver!\33[0m" exit } #Start from here. if [[ $1 != "--show" ]] then $0 --show& RunAsKeyReceiver $! exit else RunAsDisplayer exit fi
  KornLee 当前离线   回复时引用此帖
旧 03-11-18, 14:04 第 65 帖
lordbyorn
 
lordbyorn 的头像
 
 
临时退役版主  
  注册日期: May 2003
  帖子: 889
  精华: 1
 

标题: 写个脚本,for gentoo


作者: lordbyorn兄

脚本说明:
用emerge -up world >log可以得到要升级的包
bash update.sh log 可以得到升级每个包的脚本
包升级后脚本自毁

代码:
cat update.sh #!/bin/bash #update.sh sed '1,4d' $1 > tmp1 sed 's/^.*\///' tmp1 > tmp2 sed 's/-[0-9].*$//' tmp2 > tmp rm tmp1 tmp2 a=0 b=0 c=0 for package in $(< ./tmp) do cat > $a$b$c$package <<EOF #!/bin/bash if emerge $package; then rm $a$b$c$package else echo "Error in executing $a$b$c$package" >>log fi EOF chmod +x $a$b$c$package let c++ if [[ $c -eq 10 ]]; then let c=0 let b++ fi if [[ $b -eq 10 ]]; then let b=0 let a++ fi done rm tmp

此帖于 03-11-18 22:57 被 lordbyorn 编辑.
  lordbyorn 当前离线   回复时引用此帖
旧 03-12-10, 21:12 第 66 帖
KornLee
 
 
 
★☆★☆★☆★  
  注册日期: Nov 2002
  我的住址: LinuxWorld
  帖子: 6,960
  精华: 61
 

标题: 用echo显示颜色的脚本[转]


转自:www.linuxeden.com
感谢作者:dearvoid
代码:
#!/bin/bash T='gYw' # The test text echo echo " default 40m 41m 42m 43m 44m 45m 46m 47m" ## FGs 为前景(foreground)色, BG 为背景(background)色 for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' ' 36m' '1;36m' ' 37m' '1;37m' do FG=$(echo $FGs|tr -d ' ') echo -en " $FGs \033[$FG $T " for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do echo -en " \033[$FG\033[$BG $T \033[0m" done echo done echo
  KornLee 当前离线   回复时引用此帖
旧 03-12-12, 00:26 第 67 帖
KornLee
 
 
 
★☆★☆★☆★  
  注册日期: Nov 2002
  我的住址: LinuxWorld
  帖子: 6,960
  精华: 61
 

标题: 利用鼠标右键建立新文件脚本


来自: http://www.linuxsir.org/bbs/showthre...threadid=15344
作者:dany
代码:
#!/bin/sh if [ -f Newfile.txt ] then for num in 1 2 3 4 5 6 7 8 9; do { if [ -f "Newfile${num}.txt" ] then continue else { eval "touch Newfile$num.txt" break } fi } done else eval "touch Newfile.txt" fi
  KornLee 当前离线   回复时引用此帖
旧 03-12-12, 19:39 第 68 帖
home
 
 
 
已封禁  
  注册日期: Nov 2003
  帖子: 1,150
  精华: 5
 

Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Aug 05, 2002 at 02:13:06PM +0200, ROSSEL Olivier wrote:
> BTW? I am currently making some customizations of the official
> CD so it can fit into a credit-card CD (:150Mb).
> I used a tip that was sent on the list a fewx weeks ago.
> I still have a few problems (something like 'read-only filesystem')
> when depmod -a is launched. But I presume I made something wrong.
> I will have a look later.
>
> My current operating procedure is:
> boot on Knoppix-CD.
> Copy / to a directory on the hard drive.

You should copy /KNOPPIX/*, not / !

> Chroot to it.
> Make all the apt-XXX I want.
> Leave the chroot.
> Use the magical sabbat trick to create the KNOPPIX file.
>
> I think you told me a long time ago that
> /var needed to be cleaned up before you can make
> a clean KNOPPIX file. And that you use scripts to
> clean it up.

I'm sending it again as Attachment.

Regards
-Klaus Knopper
--
Klaus Knopper Technical Solutions & Finances
knopper@linuxtag.org http://www.linuxtag.org/
Phone +49-(0)631-3109371 Fax +49-(0)631-3109372
LinuxTag 2003 - Europes largest Linux Expo Where .com meets .org

--XF85m9dhOBO43t/C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Knoppix.clean"

#!/bin/sh
umask 022

/etc/init.d/autofs stop

# remove only "temporary" or saved files in the given directories
nuke(){
for i in `find "$@" -name \*.gz -o -name \*.bz2 -o -name \*.0 -o -name \*.0.log -o -name browse.dat 2>/dev/null`; do
rm -f "$i"
done
}

# set all files in the given directories to a length of zero
zero(){
for i in `find "$@" -type f -size +0 -not -name \*.ini 2>/dev/null`; do
:> "$i"
done
}

rmdir /mnt/cdrom?* /mnt/hd?* 2>/dev/null
rm -f /etc/ifstate /etc/X11/XF86Config /etc/X11/XF86Config-4 \
/etc/XF86Config /etc/XF86Config-4 /etc/sysconfig/* \
/etc/ssh/*key* \
/etc/samba/*.SID /var/lib/samba/* /var/cache/samba/* /etc/samba/*.tdb \
/dev/mouse* /dev/cdrom* /dev/cdwriter* \
/var/run/*/* /var/run/* /var/log/ksymoops/* /var/lock/*/* /var/lock/* \
/var/state/*/* /var/state/* /var/log/nessus/* /var/lib/nessus/* \
/halt /reboot /ash.static /etc/dhcpc/*.info /etc/dhcpc/resolv* \
/etc/resolv.conf /etc/*passwd- /etc/*shadow- /etc/*group- 2>/dev/null
mkdir -p /etc/sysconfig/network-scripts /etc/sysconfig/provider
cat >/etc/dhcpc/resolv.conf <<EOT
# insert nameservers here
# nameserver 127.0.0.1
EOT
chmod 644 /etc/dhcpc/resolv.conf
ln -s /etc/dhcpc/resolv.conf /etc/
rm -rf /tmp/* /var/tmp/* /var/backups/* /.ssh /root/.ssh /home/*/.ssh \
/root/.bash_history /home/*/.bash_history \
/home/knoppix/* /home/knoppix/.??* /var/lib/texmf/ls-R \
/var/spool/texmf/ls-R /var/run/screen/*
nuke /var/log /var/cache
zero /var/local /var/log /var/spool /var/mail \
/var/lib/games /var/cache/man /var/lib/wine \
/var/lib/nfs /var/lib/xkb

for i in `find /usr/*/man -name \*.\[0-9ln\]` ; do
[ -f "$i".gz -o -f "$i".bz2 ] && rm -f "$i"
done

# delete old dowloaded packages
apt-get clean

# Recreate empty utmp and wtmp
:>/var/run/utmp
:>/var/run/wtmp
# regenerate module dependencies and ls.so.cache
echo -n "Updating ld.so.cache..."
ldconfig
echo " Done."
echo -n "Updating modules.dep..."
depmod -a 2>/dev/null
echo " Done."
echo -n "Updating texhash..."
mktexlsr
echo " Done."
echo -n "Updating mandb..."
mandb -c
man doesnotexist >/dev/null 2>&1
echo " Done."
echo -n "Updating menus..."
/usr/sbin/mkmenusfromkde
echo " Done."
echo -n "Updating locate-database..."
updatedb --prunepaths="/KNOPPIX.build /mnt/hd /mnt/cdrom /tmp /usr/tmp /var/tmp"
echo " Done."

echo -n "Fixing permissions in /dev/..."
chown root.root /dev/ttyp*
chmod 666 /dev/ttyp* /dev/sg* /dev/audio* /dev/dsp* /dev/mixer* /dev/sequencer*
echo " Done".

echo -n "Removing unused architecture Kernel sources: "
for i in `ls -1 /usr/src/linux/arch/ | grep -v i386`; do
echo -n "$i "; rm -rf /usr/src/linux/arch/"$i" /usr/src/linux/include/asm-"$i"
done
echo " Done."

echo -n "Creating auto.mnt..."
cat >/etc/auto.mnt <<EOT
# Knoppix automounter file for Directory /mnt/auto
# umask=000 only works for msdos/vfat floppies, but otherwise the floppy is read-only.
floppy -fstype=auto,user,exec,umask=000 :/dev/fd0
cdrom -fstype=auto,user,exec,ro :/dev/cdrom
# The following entries (if any) are auto-generated by knoppix-autoconfig
EOT
echo " Done".
echo "Setting OpenOffice Link to default EN"
rm -f /etc/alternatives/soffice.resource ; ln -sf /opt/openoffice/program/resource-en /etc/alternatives/soffice.resource

--XF85m9dhOBO43t/C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Knoppix.postupgrade"

#!/bin/sh
# Remove unwanted init scripts and KDE-autostart files

STOP=""
for i in `ls -d1 /etc/rc?.d/* | egrep -v -e '(README|knoppix|xsession)'`; do
BASE=`basename $i`
BASE=${BASE##[KS]??}
case "$STOP" in *${BASE}*) ;; *) STOP="$STOP $BASE"; ;; esac
rm -vf $i
done

for i in $STOP; do
/etc/init.d/$i stop
done


for i in `ls -d1 /usr/share/autostart/* | egrep -v -e '(panel|kdesktop|khotkeys)\.desktop'`; do
rm -vf $i
done

chmod u+s /usr/bin/cdrecord /usr/bin/cdrdao /usr/bin/cdparanoia

# Some GTK programs HAVE to run as root. :-/

for i in `egrep -q -l -r -e '(xcdroast|ethereal)' /usr/share/applnk/.`; do
perl -pi -e 's|Exec=/|Exec=sudo /|g' "$i"
done

# Replace kdesu (needs password) by sudo (doesn't)
for i in `grep -q -l -r 'Exec=.*kdesu' /usr/share/applnk/.`; do
perl -pi -e 's|Exec=.*kdesu |Exec=sudo -H |g' "$i"
done

# Remove -ncp in xboard startup file
for i in `grep -q -l -r 'Exec=.*xboard.*-ncp' /usr/share/applnk/.`; do
perl -pi -e 's| -ncp||g' "$i"
done

for i in "alias net-pf-17 af_packet" "alias ide_cs ide-cs" "alias usbcore off" "alias autofs autofs4"; do
grep -q "$i" /etc/modutils/aliases || { echo "$i" >> /etc/modutils/aliases; update-modules; }
done

#for i in "vendor 0x055d product 0x9001 module pwc"; do
#grep -q "$i" /etc/usbmgr/usbmgr.conf || echo "$i" >> /etc/usbmgr/usbmgr.conf
#done

# Euro font stuff
perl -pi -e 's/iso8859-1( |$)/iso8859-15$1/g' /etc/X11/fonts/misc/xfonts-base.alias && update-fonts-alias /usr/lib/X11/fonts/misc

--XF85m9dhOBO43t/C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Knoppix.mkcompressed"

#!/bin/bash

DEST="$1"

[ -z "$DEST" -o ! -d "$DEST" ] && { echo "Usage: $0 DESTINATIONDIR" >&2 ; exit 1; }
[ ! -x /usr/bin/create_compressed_fs ] && { echo "Need /usr/bin/create_compressed_fs." ; exit 1; }

# Compression blocksize (must be multiple of 512)
# All block headers must fit into a kmalloc segment (ca. 130000 bytes)
BLOCKSIZE=65536
# BLOCKSIZE=53248
# BLOCKSIZE=102400

echo -n "Update Bootfloppy file(s)? "
read answer
if [ "$answer" = "y" ]; then
cp -uv /KNOPPIX.build/Knoppix.System/bootdisk/Knoppix/boot-*.img "$DEST"/KNOPPIX/
( cd "$DEST"/KNOPPIX && ln -f -v boot-de.img boot.img ) || exit 1
fi

[ ! -f "$DEST"/KNOPPIX/boot.img ] && { echo "Missing required file $DEST/KNOPPIX/boot.img" >&2 ; exit 1; }

echo -n "Recreate KNOPPIX compressed FS? "
read answer
if [ "$answer" = "y" ]
then
rm -f "$DEST"/KNOPPIX/KNOPPIX

# Remove files that need to be autogenerated from source dir!
echo -n "Sweep/Clean system before remastering? "
read answer
[ "$answer" = "y" ] && { . /KNOPPIX.build/Knoppix.postupgrade; . /KNOPPIX.build/Knoppix.clean; }

cat >/etc/network/interfaces <<EOT
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
# automatically added when upgrading
auto lo
iface lo inet loopback

EOT

cat >/etc/dhcpc/resolv.conf <<EOT
# Insert nameservers here
# nameserver 127.0.0.1
EOT

# Mount root read-only, so no files change while generating image
mount -o ro,remount / || { echo "Error: Cannot mount / read-only" >&2 ; exit 0; }

# Hide unwanted LOCALEs.
HIDELOCALE=""
HIDEMAN=""
MYLOCALE=$(awk -F'[="_]' '/^(LANG|LANGUAGE)=/{if(!/[$]/){x=x" "$3}}END{print x}' /etc/init.d/knoppix-autoconfig)
MYLOCALE="$MYLOCALE C en uk fi ja be"
LOCALEDIR=/usr/share/locale
MANPAGEDIR=/usr/share/man
for LOCALE in `/bin/ls -1 $LOCALEDIR`; do
[ -d "$LOCALEDIR/$LOCALE/LC_MESSAGES" ] || continue
FOUND=""
for l in $MYLOCALE; do
case "$LOCALE" in $l*) FOUND="yes" ;; esac
done
if [ -z "$FOUND" ]; then
HIDELOCALE="$HIDELOCALE -m $LOCALEDIR/$LOCALE"
[ -d "$MANPAGEDIR/$LOCALE" ] && HIDELOCALE="$HIDELOCALE -m $MANPAGEDIR/$LOCALE"
fi
done

# -U implies: -d, -l, -L, -N, -relaxed-filenames, -allow-lowercase,
# -allow-multidot and -no-iso-translate
# -iso-level 3 -U -cache-inodes -no-bak -pad \
# -hide-rr-moved \
# -m /var/lib/dpkg/available\* \
SORT=""
[ -e /KNOPPIX.build/mkisofs.sort ] && SORT="-sort /KNOPPIX.build/mkisofs.sort"
# mkisofs -pad -R -l -v $SORT \
mkisofs -R -U -v $SORT \
-V "KNOPPIX ISO9660 Filesystem" \
-P "Knopper.Net http://www.knopper.net/" \
-p "Klaus Knopper <knoppix@knopper.net>" \
-hide-rr-moved -cache-inodes -no-bak -pad \
-m /proc/\* -m /tmp/\* -m /var/tmp/\* -m /home/\* -m /initrd/\* \
-m /KNOPPIX.build -m /mnt/\*/\* -m \*.dpkg-\* \
-m /mnt/hd/\* -m /mnt/hd\* -m /mnt/cdrom\* -m /etc/fstab\* \
-m /etc/sysconfig/\* -m /etc/exports -m /etc/dhcpc/dhcpcd\* \
-m /var/spool/mail/\* -m /var/spool/mqueue/\* \
-m /etc/driveprm -m .ssh -m .bash_history \
-m /etc/printcap\* -m /var/spool/cups/tmp/\* \
-m /etc/cups/certs/\* -m /etc/cups/\*.O -m /etc/cups/ppd/\* \
-m /etc/gpm.conf -m /etc/isapnp.\* -m /etc/minirc.dfl \
-m /var/cache/debconf/\*-old -m /var/lib/\*/\*- \
-m /var/lib/\*/\*-old -m /var/log/XFree86.\* \
-m /var/samba/\*.pid -m /var/lib/samba/\* -m /var/cache/samba/\* \
-m /var/mail/\* -m /var/apt/cache/archives/lock \
-m /var/log/ksymoops\* -m /var/spool/exim/db/\* -m /etc/\*.old \
-m /etc/\*.save -m /etc/ssl/certs/\* -m \*.preserved \
-m .viminfo -m .\*.swp -m lost+found \
-m /.\?\?\* -m /root/.\?\?\* -m /etc/.\?\?\* \
-m /boot/map -m /boot/boot.0\* \
-m /usr/src/kernel\*.deb -m /usr/src/kernel\*.dsc -m /usr/src/kernel\*.changes -m /usr/src/kernel\*.tar.gz \
-m /usr/src/modules/pcmcia\* \
-m /usr/src/linux\*/drivers \
-m /usr/src/linux\*/fs \
-m /usr/src/linux\*/init \
-m /usr/src/linux\*/mm \
-m /usr/src/linux\*/net \
-m /usr/src/linux\*/vmlinu\* \
-m /usr/src/linux\*/System.map \
-m /usr/src/linux\*/ipc \
-m /usr/src/linux\*/kernel \
-m /usr/src/linux\*/lib \
-m /usr/src/linux\*/Rules.make \
-m /usr/src/linux\*/scripts \
$HIDELOCALE \
/ \
| nice -5 /usr/bin/create_compressed_fs - $BLOCKSIZE \
>"$DEST"/KNOPPIX/KNOPPIX || exit 1
mount -o rw,remount /
chmod 444 "$DEST"/KNOPPIX/KNOPPIX
# swapoff /dev/hdc2 2>/dev/null
fi

mkfinal(){
TARGET="$1.iso"
# Alternate boot record
# -eltorito-alt-boot \
# -b KNOPPIX/boot-en.img -c KNOPPIX/boot.cat \
mkisofs -pad -l -r -J -v \
-sort /tmp/knoppix.sort \
-V 'KNOPPIX' -A 'KNOPPIX CD-ROM' \
-P "KNOPPER.NET http://www.knopper.net/" \
-p "KNOPPIX CD-ROM Taskforce <knoppix@knopper.net>" \
-b KNOPPIX/boot.img -c KNOPPIX/boot.cat \
-hide-rr-moved \
-o "$TARGET" "$DEST"
}

echo -n "Recreate KNOPPIX-DE isofile '$DEST.iso'? "
read answer
if [ "$answer" = "y" ]; then
# Make sure that the boot floppy file is at the beginning of the image.
# Some controllers seem to depend on this.
rm -f /tmp/knoppix.sort
echo "$DEST/KNOPPIX/boot.img 100002" >/tmp/knoppix.sort
echo "$DEST/KNOPPIX/KNOPPIX 100001" >>/tmp/knoppix.sort
echo "$DEST/Demos/Audio/*.mp3 -100000" >>/tmp/knoppix.sort
echo "$DEST/Demos/Audio/*.ogg -100000" >>/tmp/knoppix.sort
# Make final CD Image
mkfinal "$DEST"

echo -n "Recreate KNOPPIX-EN isofile '$DEST-EN.iso'? "
read answer
if [ "$answer" = "y" ]; then
( cd "$DEST"/KNOPPIX && ln -f -v boot-en.img boot.img ) || exit 1
mkfinal "$DEST-EN"
( cd "$DEST"/KNOPPIX && ln -f -v boot-de.img boot.img ) || exit 1
fi
rm -f /tmp/knoppix.sort
fi

echo -n "BURN german CD version? "
read answer
if [ "$answer" = "y" ]; then
cdrecord -v -pad -eject dev=0,1,0 speed=16 fs=24M "$DEST.iso"
fi
  home 当前离线   回复时引用此帖
旧 03-12-23, 03:03 第 69 帖
KornLee
 
 
 
★☆★☆★☆★  
  注册日期: Nov 2002
  我的住址: LinuxWorld
  帖子: 6,960
  精华: 61
 

标题: 文件中两行互换的脚本


看了CU上有人问,我也即兴来一段~~~
代码:
#!/bin/ksh (($#!=3))&&{ echo Usage:$(basename $0) num1 num2 filename;exit 1; } num=$(cat $3|wc -l) n=1 while ((n<=$num)) do case $n in $1) cat $3|sed -n ${2}p ;; $2) cat $3|sed -n ${1}p ;; *) cat $3|sed -n ${n}p ;; esac ((n+=1)) done
  KornLee 当前离线   回复时引用此帖
旧 03-12-23, 12:10 第 70 帖
wide288
 
wide288 的头像
 
 
注册会员  
  注册日期: Nov 2002
  我的住址: 辽宁省
  帖子: 2,727
  精华: 15
 

标题: [转载]安全删除和恢复文件的脚本 -- 作者:bjgirl


[原创]:安全删除和恢复文件的脚本
http://www.chinaunix.net 作者:bjgirl 发表于:2003-12-22 14:30:34

由于现在的linux文件系统大多是etx3的,一不小心删除后是无法恢复的(至少我不知道),而rm是个很危险的操作!鉴于此我写了这俩小脚本,希望GGJJ们指点!
1,用root修改rm的权限:
#chmod o-x /bin/rm
2,在用户主目录下创建个"垃圾箱"
$mkdir ~/.temp

删除文件脚本:
代码:
cat erase #!/bin/ksh (($#==0)) && { echo "No paraments!";exit 1; } for i in $* do mv -f $i ~/.temp/$(find $(pwd) -maxdepth 1 -name $i|tr "/" "=") done
恢复文件脚本:
代码:
cat unerase #!/bin/ksh (($#==0))&&{ echo "No paraments!";exit 1; } cd ~/.temp list=$(for i in $*;do ls ~/.temp|grep "\<$i\>";done) for j in $list do file=$(echo $j|tr "=" "/") mv $j ${file%/*}/${file##*/} done







__________________
my new pc: Intel Duo 1.86GHz/ 2G Mem/ GIGABYTE 965P-S3/ 250G hardware/ 艾尔莎 影雷者 7600/ DVD write rom/ netcard Marvell 88E8056/ 联志机箱/

http://gimpstore.cn/
追求一种自由,共享,与技术的极限和快乐的生活!
gimp 教程
http://www.linux-wiki.cn/work/gimp/
  wide288 当前离线   回复时引用此帖
旧 03-12-23, 22:25 第 71 帖
KornLee
 
 
 
★☆★☆★☆★  
  注册日期: Nov 2002
  我的住址: LinuxWorld
  帖子: 6,960
  精华: 61
 

标题: 一个文件夹同步脚本


作者:devel
算法:
1.先find /pathname -print >filea #获取两个文件夹里所有文件的全名。
2,比较文件,先删去要同步的文件夹里多余的文件。接着重新获得需要同步的文件夹里所有文件的全名。
3.比较文件,把源文件夹里增加的文件CP到要同步的文件夹中。
这个脚本是同步/share目录里的所有文件,需要备份到/mnt/d/share
代码:
#!/bin/bash mount /dev/hda6 /mnt/d 2>/dev/null ; unalias rm cp rm /share/c/app/*o /share/c/tmp/*o /share/c/app/*core /share/c/tmp/*core /share/c/app/a.out /share/c/tmp/a.out find /share -print >/tmp/.share_ #把/share的所有文件的全名保存到/tmp/.share_ find /mnt/d/share -print |sed 's/\/mnt\/d//g' >/tmp/.d_ chmod 700 /tmp/.share_ /tmp/.d_ count=0 for i in $(comm -23 /tmp/.d_ /tmp/.share_) ; do #比较两个文件里/tmp.d_ 与/tmp./share_的不同。 echo "/mnt/d$i" rm "/mnt/d$i" ; count=$((count+1)) #删除/mnt/d/share/*里的多余的文件和计数。 done #for command ;do command ; done的循环到此结束。 echo "del $count file at /mnt/d/share/" find /mnt/d/share -print |sed 's/\/mnt\/d//g' >/tmp/.d_ ; count=0 #重新获得文件的全名。初始化计数器。 for i in $(comm -23 /tmp/.share_ /tmp/.d_) ; do echo $i cp $i "/mnt/d$i" ; count=$((count+1)) #备份/share里新增加的文件到/mnt/d/share,同时计数。 done echo "already copied $count file from /share to /mnt/d/share " ;sync umount /mnt/d 2>/dev/null echo done
  KornLee 当前离线   回复时引用此帖
旧 03-12-26, 23:00 第 72 帖
KornLee
 
 
 
★☆★☆★☆★  
  注册日期: Nov 2002
  我的住址: LinuxWorld
  帖子: 6,960
  精华: 61
 

标题: slackware添加用户adduser脚本欣赏


转贴:北南南北
作者:Stuart Winter <stuart@polplex.co.uk>
这是slackware中的添加用户的一个脚本,感觉写的很好,就帖了上来。想和弟兄们一起学习SHELL。
代码:
#!/bin/sh ########################################################################## # Program: /usr/sbin/adduser # Purpose: Interactive front end to /usr/sbin/useradd for Slackware Linux # Author: Stuart Winter <stuart@polplex.co.uk> # based on the original Slackware adduser by Hrvoje Dogan # with modifications by Patrick Volkerding # Version: 1.05 ########################################################################## # History # ########### # v1.05 - 04/01/03 # * Advise & prevent users from creating logins with '.' characters # in the user name. # * Made pending account creation info look neater # v1.04 - 09/06/02 # * Catered for shadow-4.0.3's 'useradd' binary that no longer # will let you create a user that has any uppercase chars in it # This was reported on the userlocal.org forums # by 'xcp' - thanks. <sw,pjv> # v1.03 - 20/05/02 # * Support 'broken' (null lines in) /etc/passwd and # /etc/group files <sw> # * For recycling UIDs (default still 'off'), we now look in # /etc/login.defs for the UID_MIN value and use it # If not found then default to 1000 <sw> # v1.02 - 10/04/02 # * Fix user-specified UID bug. <pjv> # v1.01 - 23/03/02 # * Match Slackware indenting style, simplify. <pjv> # v1.00 - 22/03/02 # * Created ####################################################################### # Syntax: adduser [<new_user_name>] ####################################################################### # Path to files pfile=/etc/passwd gfile=/etc/group sfile=/etc/shells # Paths to binaries useradd=/usr/sbin/useradd chfn=/usr/bin/chfn passwd=/usr/bin/passwd chmod=/bin/chmod # Defaults defhome=/home defshell=/bin/bash defchmod=711 # home dir permissions - may be preferable to use 701, however. # Determine what the minimum UID is (for UID recycling) # (we ignore it if it's not at the beginning of the line (i.e. commented out wit h #)) export recycleUIDMIN="$(grep ^UID_MIN /etc/login.defs | awk {'print $2'} 2>/dev/ null)" # If we couldn't find it, set it to the default of 1000 if [ -z "$recycleUIDMIN" ]; then export recycleUIDMIN=1000 # this is the default from /etc/login.defs fi # This setting enables the 'recycling' of older unused UIDs. # When you userdel a user, it removes it from passwd and shadow but it will # never get used again unless you specify it expliticly -- useradd just # (appears to) looks at the last line in passwd and increments the uid # I like the idea of recycling uids but you may have very good reasons not to # (old forgotten confidential files still on the system could then be owned by # this new user). We'll set this to no because this is what the original # adduser shell script did and it's what users expect. recycleuids=no # Function to read keyboard input. # bash1 is broken (even ash will take read -ep!), so we work around # it (even though bash1 is no longer supported on Slackware). function get_input() { local output if [ "`echo $BASH_VERSION | cut -b1`" = "1" ]; then echo -n "${1} " >&2 ; # fudge for use with bash v1 read output else # this should work with any other /bin/sh read -ep "${1} " output fi echo $output } # Function to display the account info function display () { local goose goose="$(echo $2 | cut -d ' ' -f 2-)" # lop off the prefixed argument useradd needs echo -n "$1 " # If it's null then display the 'other' information if [ -z "$goose" -a ! -z "$3" ]; then echo "$3" else echo "$goose" fi } # Function to check whether groups exist in the /etc/group file function check_group () { local got_error group if [ ! -z "$@" ]; then for group in $@ ; do local uid_not_named="" uid_not_num="" grep -v "$^" $gfile | awk -F: '{print $1}' | grep "^${group}$" >/dev/null 2> &1 || uid_not_named=yes grep -v "$^" $gfile | awk -F: '{print $3}' | grep "^${group}$" >/dev/null 2> &1 || uid_not_num=yes if [ ! -z "$uid_not_named" -a ! -z "$uid_not_num" ]; then echo "- Group '$group' does not exist" got_error=yes fi done fi # Return exit code of 1 if at least one of the groups didn't exist if [ ! -z "$got_error" ]; then return 1 fi } #: Read the login name for the new user :# # # Remember that most Mail Transfer Agents are case independant, so having # 'uSer' and 'user' may cause confusion/things to break. Because of this, # useradd from shadow-4.0.3 no longer accepts usernames containing uppercase, # and we must reject them, too. # Set the login variable to the command line param echo LOGIN="$1" needinput=yes while [ ! -z $needinput ]; do if [ -z "$LOGIN" ]; then while [ -z "$LOGIN" ]; do LOGIN="$(get_input "Login name for new user []:")" ; done fi grep "^${LOGIN}:" $pfile >/dev/null 2>&1 # ensure it's not already used if [ $? -eq 0 ]; then echo "- User '$LOGIN' already exists; please choose another" unset LOGIN elif [ ! "$LOGIN" = "`echo $LOGIN | tr A-Z a-z`" ]; then # useradd does not al low uppercase echo "- User '$LOGIN' contains illegal characters (uppercase); please choose another" unset LOGIN elif [ ! -z "$( echo $LOGIN | grep '\.' )" ]; then echo "- User '$LOGIN' contains illegal characters (period/dot); please choos e another" unset LOGIN else unset needinput fi done # Display the user name passed from the shell if it hasn't changed if [ "$1" = "$LOGIN" ]; then echo "Login name for new user: $LOGIN" fi #: Get the UID for the user & ensure it's not already in use :# # # Whilst we _can_ allow users with identical UIDs, it's not a 'good thing' becau se # when you change password for the uid, it finds the first match in /etc/passwd # which isn't necessarily the correct user # echo needinput=yes while [ ! -z "$needinput" ]; do _UID="$(get_input "User ID ('UID') [ defaults to next available ]:")" grep -v "^$" $pfile | awk -F: '{print $3}' | grep "^${_UID}$" >/dev/null 2>&1 if [ $? -eq 0 ]; then echo "- That UID is already in use; please choose another" elif [ ! -z "$(echo $_UID | egrep [A-Za-z])" ]; then echo "- UIDs are numerics only" else unset needinput fi done # If we were given a UID, then syntax up the variable to pass to useradd if [ ! -z "$_UID" ]; then U_ID="-u ${_UID}" else # Will we be recycling UIDs? if [ "$recycleuids" = "yes" ]; then U_ID="-u $(awk -F: '{uid[$3]=1} END { for (i=ENVIRON["recycleUIDMIN"];i in u id;i++);print i}' $pfile)" fi fi #: Get the initial group for the user & ensure it exists :# # # We check /etc/group for both the text version and the group ID number echo needinput=yes while [ ! -z "$needinput" ]; do GID="$(get_input "Initial group [ users ]:")" check_group "$GID" if [ $? -gt 0 ]; then echo "- Please choose another" else unset needinput fi done # Syntax the variable ready for useradd if [ -z "$GID" ]; then GID="-g users" else GID="-g ${GID}" fi #: Get additional groups for the user :# # echo needinput=yes while [ ! -z "$needinput" ]; do AGID="$(get_input "Additional groups (comma separated) []:")" AGID="$(echo "$AGID" | tr -d ' ' | tr , ' ')" ; # fix up for parsing if [ ! -z "$AGID" ]; then check_group "$AGID" # check all groups at once (treated as N # of params) if [ $? -gt 0 ]; then echo "- Please re-enter the group(s)" else unset needinput # we found all groups specified AGID="-G $(echo "$AGID" | tr ' ' ,)" fi else unset needinput # we don't *have* to have additional groups fi done #: Get the new user's home dir :# # echo needinput=yes while [ ! -z "$needinput" ]; do HME="$(get_input "Home directory [ ${defhome}/${LOGIN} ]")" if [ -z "$HME" ]; then HME="${defhome}/${LOGIN}" fi # Warn the user if the home dir already exists if [ -d "$HME" ]; then echo "- Warning: '$HME' already exists !" getyn="$(get_input " Do you wish to change the home directory path? (Y/n) " )" if [ "$(echo $getyn | grep -i "n")" ]; then unset needinput fi else unset needinput fi done HME="-d ${HME}" #: Get the new user's shell :# echo needinput=yes while [ ! -z "$needinput" ]; do unset got_error SHL="$(get_input "Shell [ ${defshell} ]")" if [ -z "$SHL" ]; then SHL="${defshell}" fi # Warn the user if the shell doesn't exist in /etc/shells or as a file if [ -z "$(grep "^${SHL}$" $sfile)" ]; then echo "- Warning: ${SHL} is not in ${sfile} (potential problem using FTP)" got_error=yes fi if [ ! -f "$SHL" ]; then echo "- Warning: ${SHL} does not exist as a file" got_error=yes fi if [ ! -z "$got_error" ]; then getyn="$(get_input " Do you wish to change the shell? (Y/n) ")" if [ "$(echo $getyn | grep -i "n")" ]; then unset needinput fi else unset needinput fi done SHL="-s ${SHL}" #: Get the expiry date :# echo needinput=yes while [ ! -z "$needinput" ]; do EXP="$(get_input "Expiry date (YYYY-MM-DD) []:")" if [ ! -z "$EXP" ]; then # Check to see whether the expiry date is in the valid format if [ -z "$(echo "$EXP" | grep "^[[:digit:]]\{4\}[-]\?[[:digit:]]\{2\}[-]\?[[ :digit:]]\{2\}$")" ]; then echo "- That is not a valid expiration date" else unset needinput EXP="-e ${EXP}" fi else unset needinput fi done # Display the info about the new impending account echo echo "New account will be created as follows:" echo echo "---------------------------------------" display "Login name.......: " "$LOGIN" display "UID..............: " "$_UID" "[ Next available ]" display "Initial group....: " "$GID" display "Additional groups: " "$AGID" "[ None ]" display "Home directory...: " "$HME" display "Shell............: " "$SHL" display "Expiry date......: " "$EXP" "[ Never ]" echo echo "This is it... if you want to bail out, hit Control-C. Otherwise, press" echo "ENTER to go ahead and make the account." read junk echo echo "Creating new account..." echo echo # Add the account to the system CMD="$useradd "$HME" -m "$EXP" "$U_ID" "$GID" "$AGID" "$SHL" "$LOGIN"" $CMD if [ $? -gt 0 ]; then echo "- Error running useradd command -- account not created!" echo "(cmd: $CMD)" exit 1 fi # Set the finger information $chfn "$LOGIN" if [ $? -gt 0 ]; then echo "- Warning: an error occurred while setting finger information" fi # Set a password $passwd "$LOGIN" if [ $? -gt 0 ]; then echo "* WARNING: An error occured while setting the password for" echo " this account. Please manually investigate this *" exit 1 fi # If it was created (it should have been!), set the permissions for that user's dir HME="$(echo "$HME" | awk '{print $2}')" # We have to remove the -g prefix if [ -d "$HME" ]; then $chmod $defchmod "$HME" fi echo echo echo "Account setup complete." exit 0
  KornLee 当前离线   回复时引用此帖
旧 03-12-27, 18:50 第 73 帖
KornLee
 
 
 
★☆★☆★☆★  
  注册日期: Nov 2002
  我的住址: LinuxWorld
  帖子: 6,960
  精华: 61
 

标题: 终止进程的脚本


来自: <<Red Hat Linux 8 宝典>>
代码:
#!/bin/bash # for i in `echo $*`;do for j in 15 2 1 9;do kill -$j $i && sleep 1 done done exit 0
  KornLee 当前离线   回复时引用此帖
旧 03-12-27, 22:30 第 74 帖
KornLee
 
 
 
★☆★☆★☆★  
  注册日期: Nov 2002
  我的住址: LinuxWorld
  帖子: 6,960
  精华: 61
 

标题: 查询用户登录总时间脚本


作者:javalee
代码:
[/home/javalee/myshell]cat logtime #!/bin/ksh #这是一个查询用户登录系统总时间的脚本 # #脚本开始 (($#>0))&&{ echo "Usage:$(basename $0) [Enter]";exit 1; } read name?"input username:" if ! grep -q "\<$name\>" /etc/passwd;then echo "No Found User:$1!" exit fi #定义_do函数 function _do { last $name|sed -n '2,$p'|sed 's/ \(([0-2][0-2]:[0-5][0-9])\)/#\1/g;s/(//g;s/)//g'|cut -f2 -d"#"|\ awk -F: '{sum1+=$1;sum2+=$2};END{print sum1,sum2}' } # #生成小时和分钟的变量 HH=$(_do|cut -f1 -d" ") MM=$(_do|cut -f2 -d" ") # # #取出小时和分钟 #判断分钟域,如果$MM大于60,那么换算并显示结果 if [[ $MM -gt 60 ]]; then ((m1=$MM/60)) ((m2=$MM%60)) echo "用户$name登录系统总时间:$((m1+$HH))小时$m2分" else echo "用户$name登录系统总时间:$HH小时$MM分" fi # # #脚本结束

此帖于 03-12-27 22:56 被 KornLee 编辑.
  KornLee 当前离线   回复时引用此帖
旧 03-12-29, 03:42 第 75 帖
KornLee
 
 
 
★☆★☆★☆★  
  注册日期: Nov 2002
  我的住址: LinuxWorld
  帖子: 6,960
  精华: 61
 

标题: 拨号计时脚本


作者:javalee
代码:
[/home/javalee]cat ~/myshell/ppp #!/bin/ksh #本脚本用于统计每次拨号上网所耗时间,用帽拨号的也许用得着. #放在/etc/rc.d/rc.local中,/xxx/xxx/ppp&,脚本要用绝对路 #径!另外将 #数据文件改成666即可 # #脚本开始 #建立函数_ps,便于重复调用. function _ps { ps -e|grep pppd; } line=$(cat /home/javalee/.log.txt|wc -l) #进入主循环. # while true;do #辅循环,如果pppd进程存在,则跳过此循环,否则等待. until _ps>/dev/null 2>&1;do sleep 1 done #pppd进程存在,找出进程启动时间.并将此时间添加至文件/home/javalee/.log.txt echo "上线时间:$(date +%T)" >>/home/javalee/.log.txt uptime=$(date +%s) #辅循环,pppd进程存在,则等待,否则,将当前时间添加至文件/home/javalee/.log.txt while _ps >/dev/null 2>&1;do sleep 1 done echo "下线时间:$(date +%T)" >>/home/javalee/.log.txt downtime=$(date +%s) #pppd进程已经不复存在,统计时间.并将结果添加至文件/home/javalee/.log.txt ((result_time=$downtime-$uptime)) H=$(($result_time/3600)) M=$(($result_time%3600)) if [[ $M -ge 59 ]];then M1=$(($M/60));M2=$(($M%60)) echo "第$line次上网在$(date +%m月%d日):用时:$H小时$M1分$M2秒">>/home/javalee/.log.txt else echo "第$line次上网在$(date +%m月%d日):用时:$H时$M分0秒">>/home/javalee/.log.txt fi ((line+=1)) #继续主循环. continue done
写了这个脚本,每次我就知道我每次上网的时间,用时多少啦,

此帖于 03-12-29 12:31 被 KornLee 编辑.
  KornLee 当前离线   回复时引用此帖
发表新主题 回复


主题工具

发帖规则
您 [不可以] 发表新主题
您 [不可以] 回复主题
您 [不可以] 上传附件
您 [不可以] 编辑您的帖子

已 [启用] BB 代码
已 [启用] 表情符号
已 [启用] IMG 代码
已 [禁用] HTML 代码
[论坛跳转…]


所有时间均为[北京时间]。现在的时间是 12:16


Powered by vBulletin 版本 3.6.8
版权所有 ©2000 - 2012, Jelsoft Enterprises Ltd.
官方中文技术支持: vBulletin 中文
版权所有 ©2002 - 2011, LinuxSir.Org