[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Awk, filtering match through external command



On Sat, Nov 10, 2012 at 04:28:29AM +0000, T o n g wrote:
> 
> It's OK to:
> 
>  head /etc/group | awk '{print $0 | "cut -d':' -f1";}'

Why not:

head /etc/group | awk -F: '{print $1}'

> 
> or, 
> 
>  head /etc/group | awk '{ "echo " $0 | getline result ; print result}'
> 
> Any way to filter through external command to variable, somewhat like:
> 
>  head /etc/group | awk '{print $0 | "cut -d':' -f1" | getline result ;}'
> 
> Any way to make it works?

Well...

head /etc/group |\
awk '{"echo " $0 " | cut -d: -f1" | getline result; print result}'

...seems to work. But it is also very silly.

-- 
John


Reply to: