Awk with bash variables Simply pass a variable to awk awk -v id=3E2426 '{if (match($1,id)) {print $3}}' mydata_search.dat