s2p-Sed to Perl translator
(a) ¨Ï¥Îlinux redhat 7.0¡As2p©Ò¦bªº¦ì¸m¬O/usr/bin/s2p
(b) ¨Ï¥Î¡@ldd /usr/bin/s2p¡@«áÅã¥Ü : "not a dynamic executable" ¡@¡@
(c) ©Mawk¤@¼Ë¡Aperl¦b»y·N¤W¤]¬Oawkªº¶W¶°¦X¡A©Ò¥H§Ṳ́]¥i¥H¥ÎÂà´«µ{¦¡s2p§âsedµ {¦¡Âনperl¡Cs2pªº¥Îªk©Ma2p¤@¼Ò¤@¼Ë¡A¤£¹Ls2pÂà´«®É¤L¥G¤£·|¥X¿ù¡A©Ò¥H¥i¥H©ñ¤ß¨Ï¥Î¡C°õ¦æÂà´«« ᪺µ{¦¡®É¡A¥i¥H¥Î©Î¤£¥Î-n¿ï¶µ¡A·N¸q©Msedªº¦P¦W¿ï¶µ¤@¼Ë¡C¦pªG¥[¤W-n¡AÂà´«¹Lªºµ {¦¡·|¥ý°eµ¹cªº«e¸m³B²z¾¹(preprocessor)¡A©Ò¥H¶}©l®É·|µy·LºC¤@ÂI¡C¦pªG¥i¨Æ¥ý±oª¾©I¥s¦¹µ {¦¡®É¤£·|¥Î¨ì ¡Ðn¿ï¶µ¡A¥i¥H¦b¥Îs2pÂà´«®É¥[-n©M-p³o¤GӰѼơA³qª¾s2p¶i¦æ³Ì¹Å¤Æ¡C
(d) °Ñ¼Æªº·N¸q
¡@¡@¥Îªk¡Gs2p [options] filename
- D
³]¥ß°£¿ùºX¼m
¡@¡@
- n
³oÓsed script¬O©Msed -n Ãö³sªº¡Asedªº¥Îªk½Ð¬dman sed¡C
¡@¡@-p¡@
³oÓsed script¬O©Msed -n µLÃöªº¡C¡@
¡@¡@¨Ò¤l¡G
| (¢°)sed -n '/sentimental/p'filex | |
| ¦b¿Ã¹õ¤W¦L¥X©Ò¦³¥]§tsentimentalªº¦æ¡CY¨S¦³-n¿ï¶µ¡A©Ò¦³¥]§tsentimentalªº¦æ³£·|Åã | ¥Ü¨â¦¸¡Cfilex¤£·|³Q§ïÅÜ¡C |
(¢±)sed -n '15,20p'filex
·|Åã¥Ü²Ä15¨ì20¦æ¡C
(e) -d¡@
¬O¥Îdebug¥Îªº
¡@¡@-n¡@¥Dn¬O¥i¥H°w¹ï¬YÓ¯S©wªº¼Ë¦¡¨Ó°µ³B²z¡C ¡@
¡@
(f)¡@°²³]¦³¤@ÀÉ®×dataªº¤º®e¦p¤U¡G
####################################################################
# northwest NW CharlesMain 3.0 .98 3 34 #
# western WE Sharon Gray 5.3 .97 5 23 #
# southwest SW Lewis Dalsass 2.7 .8 2 18 #
####################################################################
¦Ó¥t¤@Ó¥i°õ¦æÀÉb¦p¤U¡G
| ##################################################################### | |
| # | /eastern/,/southeast/{ # |
| # | /^*$/d # |
| # | /Suan/{h;d;} # |
|
|
|
| # | /Ann/g # |
| # | s/TB\(Savage\)/thomas\1/ # |
| ##################################################################### | |
| ¥i°õ¦æÀÉb·|¹ïÀÉ®×data°µ³B²z¡A²{¦b§Ú¤U¤F¤@Ós2p bªº«ü¥O¡A¹L«á·|Åã¥ÜÂনperlªºµ²ªG¡G | |
| ##################################################################### | |
| # | #!/usr/bin/perl # |
| # | eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' # |
| # | if $running_under_some_shell; # |
|
|
|
| # | while ($ARGV[0] =~ /^-/) { # |
| # | $_ = shift; # |
| # | last if /^--/; # |
| # | if (/^-n/) { # |
| # | $nflag++; # |
| # | next; # |
|
|
|
| # | die "I don't recognize this switch: $_\\n"; # |
|
|
|
| # | $printit++ unless $nflag; # |
|
|
|
| # | $\ = "\n"; # automatically add newline on print # |
|
|
|
| # | LINE: # |
| # | while (<>) { # |
| # | chop; # |
| # | if (/eastern/.../southeast/) { # |
| # | if (/^*$/) { # |
| # | $printit = 0; # |
| # | next LINE; # |
|
|
|
| # | if (/Suan/) { # |
| # | $hold = $_; # |
|
|
|
| # | $_ = $hold if /Ann/; # |
| # | s/TB(Savage)/thomas$1/; # |
|
|
|
| # | continue { # |
| # | if ($printit) # |
| # | { print; } # |
|
|
|
| # | { $printit++ unless $nflag; } # |
|
|
|
| ##################################################################### | |
| Âà´«¦¨perlµ{¦¡Àx¦s¥H«á¡An¥Îchmod +x ¨Ó¨Ïperlµ{¦¡¥i¥H°õ¦æ¡A®ÄªG¸ò쥻ªºµ{¦¡¤@¼Ë¡C¦pªGÂà´«¥H«áªºperlµ{¦¡µLªk°õ¦æ¡A¨º´Nn¦Û¤wdebug¤F¡C | |