The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
get sysname with getline in awk timj123 Shell Programming and Scripting 2 02-24-2008 07:43 PM
NAWK getline function Raynon Shell Programming and Scripting 5 11-28-2007 12:30 AM
awk getline help maybe? chlawren Shell Programming and Scripting 0 10-24-2007 07:56 AM
utility of getline here? remid1985 UNIX for Dummies Questions & Answers 3 11-12-2006 10:38 AM
getline with a unique gozer13 Shell Programming and Scripting 6 03-03-2005 09:20 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-11-2006
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
awk:Problem with getline

Code:
$ echo |awk ' BEGIN {"date" | getline current_time;close("date");print "Report printed on " current_time}'                                                               
Report printed on Thu May 11 14:57:29 METDST 2006
This example works fine but how can i print all the output when is longer than 1 line??

Thx in advance.
Reply With Quote
Forum Sponsor
  #2  
Old 05-11-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,016
Quote:
Originally Posted by Klashxx
Code:
$ echo |awk ' BEGIN {"date" | getline current_time;close("date");print "Report printed on " current_time}'                                                               
Report printed on Thu May 11 14:57:29 METDST 2006
This example works fine but how can i print all the output when is longer than 1 line??

Thx in advance.
pls elaborate of what you're looking for - it's a bit vague. An example could be helpful.
Reply With Quote
  #3  
Old 05-11-2006
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
Of course , i want to execute a system function (output longer than 1 line) and capture all the results.

This "bad" ex shows 1 line only:
Code:
$ awk ' BEGIN {"who" | getline USERS;close("who");print USERS}'
jefe       pts/1        May 12 07:04
Apparently the 'while ( (getline < "data") > 0 )' structure only handles files.

Thanks.
Reply With Quote
  #4  
Old 05-12-2006
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
Ok , issue solved !

This piece did the job:
Code:
awk ' BEGIN { while (("who" | getline) > 0){print};close("who")}'
Cheers
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0