摘要: 星期二 10 7月 2012 1、打印工作目录文件夹实例for i in *doif [ -d "$i" ]thenecho "$i"fidone2、打印命令行参数for arg in $@doecho "$arg"done3、打印用户信息#! /bin/bashif [ $# -eq 0 ]thenecho "Useage:demo user1 user2..." 1>&2 #print error message to standard errorexit 1fifor user in $@do 阅读全文
posted @ 2012-07-10 22:29 一宁 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 星期日 08 7月 2012 aek 是一种模式扫描和处理语言,它搜索一个或者多个文件,以查看这些文件是否存在匹配指定模式的记录。它在处理时不区分数字和文本。1.awk -F : '$1 ~ /^s/ {print $1} ' /etc/passwd #在/etc/passwd文件中,搜索每行记录的第一个字段首字母为s的字段。2.awk -F : '$1 ~ /^[sr]/ {print $1 ,"$"$2 }' /etc/passwd #在文件/etc/passwd中,搜索每行记录的第二个字段首字母为s或者r的字段。3.awk -F : & 阅读全文
posted @ 2012-07-10 22:28 一宁 阅读(261) 评论(0) 推荐(0) 编辑
摘要: #这个实例计算在命令行上指定的某个文件中的每一列数字的总和。if (test $# = 0)thenecho "you must apply a number."exit 1ficat $1 | awk ' NR == 1 # awk < $1{ nfields = NF #set nfields to number of fields in the record (NF) }{if($0 ~ /[^0-9. \t]/) #check each record to see if it contains any characters a... 阅读全文
posted @ 2012-07-10 22:27 一宁 阅读(229) 评论(0) 推荐(0) 编辑