Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: awk and ksh question

Re: awk and ksh question

From: <Jared.Still_at_radisys.com>
Date: Mon, 03 Feb 2003 17:28:56 -0800
Message-ID: <F001.00542955.20030203172856@fatcity.com>


Lisa,

Try:

export FILE=$1
print File is $FILE
for PAGER in ${*-$(awk -v FILE=$FILE '!/^#/ {print FILE}' dba_oncall.txt)};
do
print $PAGER
done

"Koivu, Lisa" <Lisa.Koivu_at_efairfield.com> Sent by: root_at_fatcity.com
 02/03/2003 01:28 PM
 Please respond to ORACLE-L  

        To:     Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>
        cc: 
        Subject:        awk and ksh question


Hello everyone,
I'm trying to awk through a text file and use that with a passed-in message to send email. Here's an example of my text file: # DBA's on call
9991234567_at_pageme.com # Lisa pager
lisa.koivu_at_efairfield.com # Lisa email Here's my awk statement, which works properly awk '!/^#/ {print $1}' filename.txt
prints the first entry in each file and skips any lines starting with #. So I put it in a loop. I don't quite understand all the syntax here, I'm pulling the exact syntax out of Steve Adams' database check script.
--

for PAGER in ${*-$(awk '!/^#/ {print $1}' dba_oncall.txt)} do
print $PAGER
done
--

Works fine.

Now when I try to pass in a parameter in $1 (which I mean to be the email message), awk grabs it and the script no longer works. Like this

--

export FILE=$1
print File is $FILE
for PAGER in ${*-$(awk '!/^#/ {print $1}' dba_oncall.txt)}; do
print $PAGER
done
--

This prints the name of the file in both print statements, before and inside the loop. What am I doing wrong?

Also if anyone can explain in a nutshell what the ${} means (I think it means consider the results as a variable) and the * and - and $() means in the for/do loop syntax I would be grateful. I'm leafing through my ksh book but I think this is several specific functions all slapped together. Thanks to anyone that can help pull my head out of the sand... Lisa Koivu
Oracle Database Administrator
Fairfield Resorts, Inc.
5259 Coconut Creek Parkway
Ft. Lauderdale, FL, USA 33063
Office: 954-935-4117
Fax: 954-935-3639
Cell: 954-683-4459

--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author:
  INET: Jared.Still_at_radisys.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Mon Feb 03 2003 - 19:28:56 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US