I have a scenario to handle. Need help with that... I have a config file and its content looks something like below:    Jobname|Type|Silo|Description    #comment1    #comment2    job1|me|silo1|test_job1    job1|me|silo1|test_job2    job1|prod|silo1|test_job3Now I need the conditional content of the file, say the content with TYPE =me.For this I am using a grep with me:      job_detail=$((cat config_file | grep me | awk '{print $4}'))In this case, I am getting the first line also , as JOBNAME is getting matching character me. I escaped comments with -v options. I can't comment the first line of the config file, as it is used by other unknown processes.Is there a way i can grep the whole word match? would be better if there is a way to grep whole word with a particular character as condition.A way to divide the line with '|' and then grep?
Conditional grepping
shell script;awk;scripting;grep;pipe
tryawk -F\| -v select=$var '$2 == select { print $4;}' config_filewhere$var contains the field you want to select-F\| tell awk to use | as separator, | (pipr) must be escaped.-v select=$var transfer $var to awk variable (select)$2 == select select line whose second arg is $var or select.{ print $4;} print fourth field.