-1

22 content:

/dev/sda3            236235512  97617352 126618008  44% /
/devtmpfs               8388608        92   8388516   1% /dev
/dev/sda1              2063504     97580   1861104   5% /boot

For scripts 1-4, the result is: /devtmpfs 8388608 92 8388516 1% /dev, but script 5 gives no output.

  1. awk -F"[ ]+" "{if(\$6 ~ /dev/) print \$0}" 22
  2. flt=dev ; awk -F"[ ]+" "{if(\$6 ~ /$flt/) print \$0}" 22
  3. awk -F"[ ]+" '{if($6 ~ flt) print $0}' flt=dev 22
  4. awk -F"[ ]+" '{if($6 ~ /dev/) print $0}' 22
  5. awk -F"[ ]+" **'{if($6 ~ /flt/)** print $0}' flt=dev 22

Does the /flt/ in the last example substitute variable 'flt' into the regular expression?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
sharingli
  • 138
  • 1
  • 7
  • where is the question? – Vijay Feb 26 '13 at 06:04
  • You got your answer but you have multiple issues in every script you posted above so if you plan to use awk I suggest you post your attempt here and ask for feedback first as you have some basic misunderstandings about awk. – Ed Morton Feb 26 '13 at 13:29
  • possible duplicate of [using variables in search pattern in awk script](http://stackoverflow.com/questions/4266770/using-variables-in-search-pattern-in-awk-script) – Jonathan Leffler Mar 03 '14 at 02:32

1 Answers1

1

/flt/ means a match with the regular expression flt, which is not present in your input file, so there is no match..

Scrutinizer
  • 9,608
  • 1
  • 21
  • 22