摘要: 1>filename # Redirect stdout to file "filename." 1>>filename # Redirect and append stdout to file "filename." 2>filename # Redirect stderr to file "filename." 2>>filename # Redirect and append stderr to file "filename." &>filename # Re 阅读全文
posted @ 2011-06-04 22:47 greencolor 阅读(203) 评论(0) 推荐(0) 编辑
摘要: n<&- Close input file descriptor n.0<&-, <&- Close stdin.n>&- Close output file descriptor n.1>&-, >&- Close stdout. 阅读全文
posted @ 2011-06-04 22:36 greencolor 阅读(132) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bash# Declare arraydeclare -a ARRAY# Link filedescriptor 10 with stdinexec 10<&0# stdin replaced with a file supplied as a first argumentexec < $1let count=0while read LINE; do ARRAY[$count]=$LINE ((count++))doneecho Number of elements: ${#ARRAY[@]}# echo array's contentecho ${A 阅读全文
posted @ 2011-06-04 21:32 greencolor 阅读(198) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bash#Declare array with 4 elementsARRAY=( 'Debian Linux' 'Redhat Linux' Ubuntu Linux )# get number of elements in the arrayELEMENTS=${#ARRAY[@]}# echo each element in array # for loopfor (( i=0;i<$ELEMENTS;i++)); do echo ${ARRAY[${i}]}done 阅读全文
posted @ 2011-06-04 21:09 greencolor 阅读(361) 评论(0) 推荐(0) 编辑
摘要: 1) SIGHUP 本信号在用户终端连接(正常或非正常)结束时发出, 通常是在终端的控制进程结束时, 通知同一session内的各个作业, 这时它们与控制终端不再关联. 2) SIGINT 程序终止(interrupt)信号, 在用户键入INTR字符(通常是Ctrl-C)时发出 3) SIGQUIT 和SIGINT类似, 但由QUIT字符(通常是Ctrl-\)来控制. 进程在因收到SIGQUIT退出时会产生core文件, 在这个意义上类似于一个程序错误信号. 4) SIGILL 执行了非法指令. 通常是因为可执行文件本身出现错误, 或者试图执行数据段. 堆栈溢出时也有可能产生这个信号. 5). 阅读全文
posted @ 2011-06-04 21:06 greencolor 阅读(181) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bashecho -e "Hi, please type the word: \c "read wordecho "The word you entered is: $word"echo -e "Can you please enter two words? "read word1 word2echo "Here is your input: \"$word1\" \"$word2\""echo -e "How do you feel about ba 阅读全文
posted @ 2011-06-04 20:14 greencolor 阅读(123) 评论(0) 推荐(0) 编辑
摘要: cat主要有三大功能:1.一次显示整个文件。$ cat filename2.从键盘创建一个文件。$ cat > filename只能创建新文件,不能编辑已有文件.3.将几个文件合并为一个文件。$cat file1 file2 > filecat具体命令格式为 : cat [-AbeEnstTuv] [--help] [--version] fileName说明:把档案串连接后传到基本输出(屏幕或加 > fileName 到另一个档案)参数:-n 或 –number 由 1 开始对所有输出的行数编号-b 或 –number-nonblank 和 -n 相似,只不过对于空白行不编 阅读全文
posted @ 2011-06-04 17:59 greencolor 阅读(150) 评论(0) 推荐(0) 编辑
摘要: \a alert (bell) \b backspace\e an escape character \f form feed\n newline \r carriage return\t horizontal tab \v vertical tab\\ backslash \` single quote\nnn octal value of characters ( see [http://www.asciitable.com/ ASCII table] ) \xnn hexadecimal value of characters ( see [http://www.asciitable.c 阅读全文
posted @ 2011-06-04 16:08 greencolor 阅读(195) 评论(0) 推荐(0) 编辑
摘要: -b filename Block special file-c filename Special character file-d directoryname Check for directory existence-e filename Check for file existence-f filename Check for regular file existence not a directory-G filename Check if file exists and is owned by effective group ID.-g filename true if file e 阅读全文
posted @ 2011-06-04 15:33 greencolor 阅读(152) 评论(0) 推荐(0) 编辑
摘要: = equal!= not equal< less then> greater then-n s1 string s1 is not empty-z s1 string s1 is empty 阅读全文
posted @ 2011-06-04 15:32 greencolor 阅读(94) 评论(0) 推荐(0) 编辑
摘要: -lt <-gt >-le <=-ge >=-eq ==-ne != 阅读全文
posted @ 2011-06-04 15:31 greencolor 阅读(101) 评论(0) 推荐(0) 编辑
摘要: for x in one two three fourdo echo number $xdonefor myfile in /etc/r*do if [ -d "$myfile" ] then echo "$myfile (dir)" else echo "$myfile" fidonefor x in /etc/r??? /var/lo* /home/drobbins/mystuff/* /tmp/${MYPATH}/*do cp $x /mnt/mydirdonewhile [ condition ]do statementsdo 阅读全文
posted @ 2011-06-04 13:11 greencolor 阅读(158) 评论(0) 推荐(0) 编辑
摘要: environment variable "$1", which referred to the first command-line argument. Similarly, you can use "$2", "$3", etc. to refer to the second and third arguments passed to your script.ex#!/usr/bin/env bashecho name of script is $0echo first argument is $1echo second argu 阅读全文
posted @ 2011-06-04 07:32 greencolor 阅读(422) 评论(0) 推荐(0) 编辑