![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how do I pass or read values from file ? | nix-kid | Shell Programming and Scripting | 1 | 05-20-2008 01:04 PM |
| How to pass values from one file to different scripts | pssandeep | UNIX for Dummies Questions & Answers | 6 | 12-14-2007 07:14 PM |
| How to pass passwords to bash scripts? | siegfried | Shell Programming and Scripting | 5 | 08-04-2006 05:59 PM |
| how to pass values from oracle sql plus to unix shell script | trichyselva | UNIX for Dummies Questions & Answers | 2 | 02-24-2006 10:19 AM |
| is it possible to pass external variable values to nawk? | swamymns | Shell Programming and Scripting | 1 | 02-02-2006 06:13 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to pass values between awk and shell scripts
I know that we can call system command to execute shell script in awk.
but it does not return the result of the command executed , but only returns the value of the command executoin status ( 1/0 --> failure / success). Could anyone let me know how to solve this problem. |
|
||||
|
|
|
||||
|
Hi,
I have the same problem and I the solutions posted here don't work for me or I don't understand them :-( So, how can I retrive in awk the returned value by a shell command and not its return status (0,1)? My problem: I want to perform some date manipulation inside awk. For this, I want to convert the dates in the number of seconds using the date shelll command. cmd=sprintf("date -d %s +%%s",d1); val=system(cmd); The problem is that val receives 0 (success) and not the number of seconds. Thanks a lot Isi |
|
||||
|
Hi
Thanks for the reply but I get an error when using getline. Is getline an standard UNIX command (I'm using cygwin :-()? Can I use it inside an awk code? My code is Code:
awk -v inicio=$f1 -v fin=$f2 '
function compareDate(d1,d2)
{
cmd=sprintf("date -d %s +%%s",d1);
system(cmd)|getline s1;
close(cmd);
cmd=sprintf("date -d %s +%%s",d2);
system(cmd)|getline s2;
close(cmd);
if (s1 > s2)
{
retVal=1;
}
else if ( s1=s2 )
{
retVal=0;
}
else
{
retVal=-1;
}
return retVal;
}
doprint==0 && compareDate($1,inicio)>=0 { doprint=1; }
doprint==1 && compareDate($1,fin)>=0 { exit; }
doprint==1 { print; }
Thanks a lot again Isi |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|