ext. command with awk variable as parameter 
Author Message
 ext. command with awk variable as parameter

Hi,

I'm trying to extract mails from a mail folder, and my problem is to call
date with awk position parameters, like this:

cmd="date -d\"" $3 " " $4 " " $5 "\"" " +%a"
day='`cmd`'
print $1, $2, day ",", $3, $4, $5, $6, $7, $8

(I tried it in one line before, but it didn't work, too).
The above command just produces a null string for day (the script is called
from inside an sh script).
Can anyone help me with this?

Timo Ollech



Tue, 21 May 2002 03:00:00 GMT  
 ext. command with awk variable as parameter


% cmd="date -d\"" $3 " " $4 " " $5 "\"" " +%a"
% day='`cmd`'

What you want is
 cmd | getline day
 close(cmd)

--

Patrick TJ McPhee
East York  Canada



Wed, 22 May 2002 03:00:00 GMT  
 ext. command with awk variable as parameter

Quote:

> Hi,

> I'm trying to extract mails from a mail folder, and my problem is to call
> date with awk position parameters, like this:

> cmd="date -d\"" $3 " " $4 " " $5 "\"" " +%a"
> day='`cmd`'
> print $1, $2, day ",", $3, $4, $5, $6, $7, $8

> (I tried it in one line before, but it didn't work, too).
> The above command just produces a null string for day (the script is called
> from inside an sh script).
> Can anyone help me with this?

> Timo Ollech

Are you using the form
day='`cmd`'
within the awk script?

Try this instead:
cmd | getline day

Bo Siltberg



Thu, 23 May 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help passing command line parameters to awk scripts

2. THANKS: Help passing command line parameters to awk script

3. Interpret awk parameter as a command

4. Pass an AWK variable to a pipeline program as a parameter

5. Sending a command line parameter %1 to a variable in my clarion program

6. Command Line Parameters/Variables

7. Command Line Parameters/Variables

8. Passing command line variables to AWK in shell script

9. Awk Command-line Variables - Thanks!

10. Awk Command-Line Variables

11. Quoting Swamp: Saving an awk command in a shell variable

12. Command line variable assignment in awk

 

 
Powered by phpBB® Forum Software