All said that the SED awk maintenance personnel's necessary tools, starting today to organize related notes, first of all to meet these two things.
Commonality: Using the same syntax [Address]/pattern/action/flag
is a character stream-oriented, read input from a bank at a time, and output to standard output, which is input-driven
are pattern-matching using regular expressions.
Allows the user to specify instructions in the script
So the individual thinks there are several aspects that need to break through: grammar, regularization, scripting ideas
[[email protected] test] #今天写的脚本显示洲及所在州的人名
#! /bin/sh
Awk-f "," ' {print $4 ', ' $} ' $* | Sort |
Awk-f "," '
$ = = LastState {print "\t\t"
$ = laststate {LastState = $1;print $1;print "\t\t" $} '
List file
John daggett,341 King Road,plymouth MA
Alice ford,22 East Broadway,richmond VA
Terry kalkas,402 Lans road,beaver Falls PA
Amy wilde,334 Bayshore Pkwy,mountain View CA
Eric adans,20 Post Road,sudbury MA
Sal carpenter,73 6th Street,boston MA
SEDSCR Processing files
s/mq/, mqwwqdhuw355w/
s/ma/, mmmmmmmmmmmm/
s/pa/, penccccccccccc/
s/ca/, california/
s/va/, virginia/
s/ok/, oklahoma/
Command Sed-f SEDSCR | Bystate output
California
Amy Wilde
Mmmmmmmmmmmm
Eric Adans
John Daggett
Sal Carpenter
Penccccccccccc
Terry Kalkas
Virginia
Alice Ford
This place has a program that is how to write your own shell programming executable
chmod +x bystate Grant Execute permission
./bystate or bash bystate execution
If prompted Bystate is not an executable program export path= $PATH:/home/test #my bystate in/home/test/
This article from "Yun Weibang" blog, declined reprint!
Sed awk notes (ii)