The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: AWK question?
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 06-23-2006
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 393
In awk:
Code:
$ cat file 
a b c d
e c g h
a b j c
$ awk -v var=c '{for (i=0;i<=NF;i++){if(var == $i){ print "Var "var" found in column "i" line "NR }}}' file
Var c found in column 3 line 1
Var c found in column 2 line 2
Var c found in column 4 line 3