Macro 32 Ramblings

Mind Archive

Two delimiters with AWK

From: http://www.unix.com/shell-programming-scripting/152934-two-delimiters-awk.html


Hello,
this thread is more about scripting style than a specific issue.
I’ve to grep from a output some lines and from them obtain a specific entry delimited by < and >.

This is my way :

Code:
1) grep -i user list | awk '{FS="<";print $NF}' | sed -e 's/>//g'
 
2) grep -i user list | cut -d"," -f 3 | cut -d '<' -f 2 | sed -e 's/>//g'

Now, I want to know if there is a best way (sure there is ) to do it.

Moreover, it is possible to put all instruction on a awk cmd ?

br/gb

——————————–
UPDATE –
A third way solution :

Code:
grep -i user list | awk -F"[<,>]"  '/>/{print $(NF-1)}'

It is fine… but not complete, cause NF is a blanck char. How to del this char from awk test ?