I have the below script saved in bin
, which is using to get output based on a defined variable.
Currently, this script is running for column 1 and providing output.
How can we update this script so it can provide output if it match on either column 1 or 2.
cat ~/bin/POUT
#!/bin/bash
exec awk -v arg=${1:?} '$1==arg' "${@:2}" inputfile
input file-:
DEV RETAIL RETAILDEVNode
TEST RETAILTEST RETAILTESTNode
TEST AUDIT AUDITTESTNode
QA AUDITQA AUDITQANode
PROD SALE SALEPRODNode
QA SALEQA SALETESTNode
QA FINANCE FINANCEQANode
PROD FINANCE FINANCEPRODNode
Currently getting Expected output-
$ POUT QA
QA AUDITQA AUDITQANode
QA SALEQA SALETESTNode
QA FINANCE FINANCEQANode
Also want output like below (search in column 2 also):
$ POUT AUDITQA
QA AUDITQA AUDITQANode
Want output like this also (put any matching value and search in column 2 aslo) ---
$ POUT DITQ
QA AUDITQA AUDITQANode
So whatever input is given in variable, it should serach in column 1 and 2 and provide output.
arg=${1:?}
will do? – Ed Morton Apr 23 '23 at 14:05