home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!ucsbcsl!ucsbuxa!6500scv1
- From: 6500scv1@ucsbuxa.ucsb.edu (Steven C. Velasco)
- Newsgroups: comp.unix.questions
- Subject: Awk: Beginner needs help!
- Keywords: awk unix
- Message-ID: <5608@ucsbcsl.ucsb.edu>
- Date: 3 Sep 92 19:32:05 GMT
- Sender: root@ucsbcsl.ucsb.edu
- Distribution: comp.unix.questions
- Lines: 42
-
-
- HI,
- I am new to unix, and really new to awk, so hopefully somebody can
- answer this question real easily. I have hundreds of SAS program
- files written for MVS, that we now need to run on UNIX.
- The files from MVS look like this :
-
- COMMAND? list unnumbered
- //MVS JCL statements
- //MVS JCL statements
- //MVS JCL statements
- DATA _NULL_ ;
- SET SASLIB.DATASET ;
- MORE SAS STATEMENTS
- RUN ;
-
- I can get awk to print out the lines that don't contain the string "//"
- or "COMMAND?" in $1, but I would like to have
- something that replaces the entire line "COMMAND? list unnumbered"
- (this is always the first line, and occurs just once)
- with the string: "libname saslib /usr2/username/datasets" or, to
- somehow put the "libname" string in the first line of each file.
- So the resulting file would look like this:
-
- libname saslib '/usr2/username/datasets' ;
- DATA _NULL_ ;
- SET SASLIB.DATASET ;
- MORE SAS STATEMENTS ;
- RUN ;
-
- below is my feeble attempt to do this. When I run this program, I
- get a message saying something like 'awk: cant set $0 at record 1':
-
- $1 !~ /\/\// { if ( $0 ~ /COMMAND? list unnumbered/ )
- $0 = "libname saslib /usr2/username/datasets ;"
- print >FILENAME }
-
- What am I doing wrong? I would appreciate any help or suggestions.
-
- Steven C. Velasco
- 6500scv1@ucsbuxa.ucsb.edu -OR-
- velasco@alishaw.ucsb.edu
-