home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnuawk.zip / awklib / eg / prog / awksed.awk < prev    next >
Text File  |  1997-03-15  |  518b  |  32 lines

  1. # awksed.awk --- do s/foo/bar/g using just print
  2. #    Thanks to Michael Brennan for the idea
  3.  
  4. # Arnold Robbins, arnold@gnu.ai.mit.edu, Public Domain
  5. # August 1995
  6.  
  7. function usage()
  8. {
  9.     print "usage: awksed pat repl [files...]" > "/dev/stderr"
  10.     exit 1
  11. }
  12.  
  13. BEGIN {
  14.     # validate arguments
  15.     if (ARGC < 3)
  16.         usage()
  17.  
  18.     RS = ARGV[1]
  19.     ORS = ARGV[2]
  20.  
  21.     # don't use arguments as files
  22.     ARGV[1] = ARGV[2] = ""
  23. }
  24.  
  25. # look ma, no hands!
  26. {
  27.     if (RT == "")
  28.         printf "%s", $0
  29.     else
  30.         print
  31. }
  32.