Shell: March 2009 Archives

Using shell variable in awk

| | Comments (0)

Shell variable must within single-quotes in awk command, just like '$A'

e.g. File fruit.txt content as follow
apple 99
orange 25
lemon 30

FRUIT=apple, To get number after $FRUIT
awk '/'$FRUIT'/ {print $2}' fruit.txt (Rignt)
awk '/$FRUIT/ {print $2}' fruit.txt (Wrong, not work)

October 2009: Monthly Archives

凱莉手工坊

凱莉手工坊

October 2009

Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

About this Archive

This page is a archive of entries in the Shell category from March 2009.

Shell: October 2009 is the next archive.

Find recent content on the main index or look in the archives to find all content.