I have a file, service_stream_mapping.dat, made of two columns, which looks something like this:
PROCESS_A DAILY_UPDATE
PROCESS_B DAILY_UPDATE
PROCESS_C WEEKLY_UPDATE
PROCESS_D MONTHLY_UPDATE
PROCESS_E WEEKLY_UPDATE
I would like to search the file using awk with a string that occurs somewhere in the 1st column and obtain the string in the 2nd column.
For example, if I search PROCESS_E, I would like the result to be WEEKLY_UPDATE.
I have tried the following so far in the korn shell;
export $JOB_STREAM="DAILY_UPDATE"
#1
$SERVICE_NAME=$(awk '/$x/ {print $2}' x='${JOB_STREAM}' service_stream_mapping.dat)
echo $JOB_STREAM
#2
$SERVICE_NAME=`awk '/$x/ {print $2}' x='${JOB_STREAM}' service_stream_mapping.dat`
echo $JOB_STREAM
#3
$SERVICE_NAME=$(awk '/'${JOB_STREAM}'/ {print$2}' service_stream_mapping.dat)
echo $JOB_STREAM
#4
$SERVICE_NAME="$(awk -v VAR='$JOB_STREAM' '/VAR/ {print $2}' service_stream_mapping.dat)"
echo $JOB_STREAM
but none of the above four results in anything!
Any help would be much appreciated!
PROCESS_A DAILY_UPDATE
PROCESS_B DAILY_UPDATE
PROCESS_C WEEKLY_UPDATE
PROCESS_D MONTHLY_UPDATE
PROCESS_E WEEKLY_UPDATE
I would like to search the file using awk with a string that occurs somewhere in the 1st column and obtain the string in the 2nd column.
For example, if I search PROCESS_E, I would like the result to be WEEKLY_UPDATE.
I have tried the following so far in the korn shell;
export $JOB_STREAM="DAILY_UPDATE"
#1
$SERVICE_NAME=$(awk '/$x/ {print $2}' x='${JOB_STREAM}' service_stream_mapping.dat)
echo $JOB_STREAM
#2
$SERVICE_NAME=`awk '/$x/ {print $2}' x='${JOB_STREAM}' service_stream_mapping.dat`
echo $JOB_STREAM
#3
$SERVICE_NAME=$(awk '/'${JOB_STREAM}'/ {print$2}' service_stream_mapping.dat)
echo $JOB_STREAM
#4
$SERVICE_NAME="$(awk -v VAR='$JOB_STREAM' '/VAR/ {print $2}' service_stream_mapping.dat)"
echo $JOB_STREAM
but none of the above four results in anything!
Any help would be much appreciated!