home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10699 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  1.6 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!ucsbcsl!ucsbuxa!6500scv1
  2. From: 6500scv1@ucsbuxa.ucsb.edu (Steven C. Velasco)
  3. Newsgroups: comp.unix.questions
  4. Subject: Awk: Beginner needs help!
  5. Keywords: awk unix
  6. Message-ID: <5608@ucsbcsl.ucsb.edu>
  7. Date: 3 Sep 92 19:32:05 GMT
  8. Sender: root@ucsbcsl.ucsb.edu
  9. Distribution: comp.unix.questions
  10. Lines: 42
  11.  
  12.  
  13. HI,
  14. I am new to unix, and really new to awk, so hopefully somebody can
  15. answer this question real easily.  I have hundreds of SAS program
  16. files written for MVS, that we now need to run on UNIX.  
  17. The files from MVS look like this :
  18.  
  19. COMMAND? list unnumbered
  20. //MVS JCL statements
  21. //MVS JCL statements
  22. //MVS JCL statements
  23. DATA _NULL_ ;
  24.    SET SASLIB.DATASET ;
  25. MORE SAS STATEMENTS
  26. RUN ;
  27.  
  28. I can get awk to print out the lines that don't contain the string  "//"
  29. or "COMMAND?" in $1, but I would like to have
  30. something that replaces the entire line  "COMMAND? list unnumbered"
  31. (this is always the first line, and occurs just once) 
  32. with the string: "libname saslib /usr2/username/datasets"  or, to 
  33. somehow put the "libname" string in the first line of each file.
  34. So the resulting file would look like this:
  35.  
  36. libname saslib '/usr2/username/datasets' ;
  37. DATA _NULL_ ;
  38.    SET SASLIB.DATASET ;
  39. MORE SAS STATEMENTS ;
  40. RUN ;
  41.  
  42. below is my feeble attempt to do this.  When I run this program, I
  43. get a message saying something like 'awk: cant set $0 at record 1':
  44.  
  45. $1 !~ /\/\// { if ( $0 ~ /COMMAND? list unnumbered/ ) 
  46. $0 = "libname saslib /usr2/username/datasets ;" 
  47. print >FILENAME }  
  48.  
  49. What am I doing wrong?  I would appreciate any help or suggestions.
  50.  
  51. Steven C. Velasco
  52. 6500scv1@ucsbuxa.ucsb.edu  -OR-
  53. velasco@alishaw.ucsb.edu
  54.