home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!milano!cactus.org!cheselka
- From: cheselka@cactus.org (Michael R. M. Cheselka)
- Subject: two simple nawk questions, Sunos 4.1.2 and nawk
- Message-ID: <1992Aug24.023958.17325@cactus.org>
- Summary: printing out ranges like $1-$19, and parameterless nawk scripts
- Organization: Capital Area Central Texas UNIX Society, Austin, Tx
- Date: Mon, 24 Aug 1992 02:39:58 GMT
- Lines: 46
-
- I am trying to nawk through a file and change in the 20th field the value
- of the date from mo/da/year, as in 02/30/1993, to mo/ld/year, as in
- 02/28/1993( where da is any particular day, even wrong ones, and ld is the
- correct last day of the month), and the two problems I can't solve are,
- that I can't get the shell wrapper to work like I would like without having
- to specify a file on the command line, and I am having trouble finding a
- way to print out the line when I am done, using ranges, like $1-$19.
-
- I would like to do:
-
- 1)
- #! /bin/nawk -f # Call the nawk script without any parameters
- BEGIN { FS = "|";
- OFS = "|" }
- { while ( getline <"Data.file" > 0 )
-
- ...rest of script...
-
- How can I run this program without having to use:
-
- mysys: ~ $ datefix Data.file
-
- In otherwords, just by typing the script name( without Data.file).
-
- 2)
- How do I specify a range for a print statement:
-
- print $1-$19,date,$21-$37
-
- Right now it seems I have to have a line like:
-
- print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14...goes on and on till
- I wanna scream!
-
- I am sorry if these are obvious questions or FAQ's, but nothing about them
- appears in the O'Rielly book, or anywhere else. I guess the creaters of
- nawk expect you to write filters like:
-
- mysys: ~ $ datefix -F\| -f20 < Data.file > Data.file.fixed
-
- but I want to do it my way.
- --
- cheselka@cactus.org N5UVV Michael R. M. Cheselka
- os9@gnu.ai.mit.edu Hangs out on 145.21mhz 400 W. 34th st. #103
- membership@cactus.org Austin, TX 78705-1331
- {...}!cs.utexas!cactus.org!cheselka (512)452-9412v ( 24hours answer. mach.)
-