|  | 
新学awk,小试一下
| 点出所有的字符a 
 R:\>type 1.txtUsage: awk [POSIX or GNU style options] -f progfile [--] file ...
 Usage: awk [POSIX or GNU style options] [--] 'program' file ...
 POSIX options:          GNU long options:
 -f progfile             --file=progfile
 -F fs                   --field-separator=fs
 -v var=val              --assign=var=val
 -m[fr] val
 -W compat               --compat
 -W copyleft             --copyleft
 -W copyright            --copyright
 -W dump-variables[=file]        --dump-variables[=file]
 -W exec=file            --exec=file
 -W gen-po               --gen-po
 -W help                 --help
 -W lint[=fatal]         --lint[=fatal]
 -W lint-old             --lint-old
 -W non-decimal-data     --non-decimal-data
 -W profile[=file]       --profile[=file]
 -W posix                --posix
 -W re-interval          --re-interval
 -W source=program-text  --source=program-text
 -W traditional          --traditional
 -W usage                --usage
 -W use-lc-numeric       --use-lc-numeric
 -W version              --version
 To report bugs, see node `Bugs' in `gawk.info', which is
 section `Reporting Problems and Bugs' in the printed version.
 gawk is a pattern scanning and processing language.
 By default it reads standard input and writes standard output.
 Examples:
 gawk '{ sum += $1 }; END { print sum }' file
 gawk -F: '{ print $1 }' /etc/passwd
 
 
 代码f.awk:
 命令:复制代码BEGIN { print "hello,world===============" }
{print $0}
{gsub(/[^a\t]/," ");print}
{gsub("a","A",$0);print}
{last=$1}
END {print "\nthe last is =" $1 }
awk  -f f.awk 1.txt
 
 
 
 
 
 
 
 
 
 hello,world===============Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
 a    a
 A    A
 Usage: awk [POSIX or GNU style options] [--] 'program' file ...
 a    a                                           a
 A    A                                           A
 POSIX options:  GNU long options:
 
 
 -f progfile  --file=progfile
 
 
 -F fs   --field-separator=fs
 a a
 A A
 ........
 
 Examples:
 a
 A
 gawk '{ sum += $1 }; END { print sum }' file
 a
 A
 gawk -F: '{ print $1 }' /etc/passwd
 a                            a
 A                            A
 the last is =A
 
 awk实在太强了,竟然有正则
 
 [ 本帖最后由 快雪时晴 于 2010-1-12 22:02 编辑 ]
 | 
 |