May 2000
Beginner
761 pages
18h 20m
English
The end result is to be able to embed the shell variable in the awk command line and have the shell expand the variable without interfering with awk's field designators, $1 and $2.
name="Jacob Savage" (sh, bash and ksh) set name = "Jacob Savage" (csh and tsh)
Jacob Savage:408-298-7732:934 La Barbara Dr. , San Jose,CA:02/27/78:500000
awk -F: '$1 ~ /^'"$name"'/{print $2}' datafile (Output) 408-298-7732
Test your knowledge of the Linux command at the command line before plugging in any shell variables.
awk -F: '$1 ~ /^Jacob Savage/{print $2}' filename (Output) 408-298-7732
Plug in the shell variable without changing anything ...
Read now
Unlock full access