![]() |
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 |
| named pipes | kanchan_agr | Shell Programming and Scripting | 5 | 09-12-2007 05:48 AM |
| Print Problem in UNIX. Need to know the option to specify the print paper size | ukarthik | HP-UX | 1 | 06-07-2007 09:35 AM |
| Two types of pipes? | blowtorch | UNIX for Dummies Questions & Answers | 5 | 10-31-2005 09:35 PM |
| cd using pipes | Sinbad | Shell Programming and Scripting | 2 | 09-09-2004 10:05 AM |
| PIPEs and Named PIPEs (FIFO) Buffer size | Jus | Filesystems, Disks and Memory | 1 | 08-20-2004 10:14 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
awk pipes & print
Hi,
I need to awk some data from some text files, basic stuff, eg: awk '/phrase/ {print $1,$2,$3}' file Which will print columns 1 to 3 of all lines containing "phrase" But what if I wanted to pipe just one of the columns to a command (in my case a date converter) as in: awk '/phrase/ {print $1 ¦ "command" ,$2,$3}' file The above does not work. Does anyone know what does? I'm using ksh. Cheers, Jon. |
|
||||
|
Your date converter has to be able to read from stdin. Your syntax is mostly correct. use getline to "retreive" your response on the other side of the pipe.
Code:
awk '/phrase/ {print $1 ¦ "command" | getline mydate; print mydate,$2,$3}' file
Code:
echo "$mydate" | date_converter |
|
||||
|
Quote:
awk '/phrase/ {system("command "$1" ");print $3" "$4}' file > output ...the only problem is the ; forces a new line. Any way around that? Jon |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|