Please assist with the following script, which is matching variable and providing output. The script is working with exact match in columns 1 and 2, but it is not providing an output when there is a partial match.
cat ~/bin/MYSH
#!/bin/bash
arg="${1:?}"
awk -v arg="${arg//\/\\}" '$1 == arg || $2 == arg' "$@" inputfile
inputfile-
1111 1111RETAIL RETAIL8888Node
2222 2222RETAIL RETAIL7777Node
3333 3333AUDITTEST AUDIT6666Node
4444 4444AUDIT AUDIT3333Node
5555 5555SALE SALE4444Node
6666 6666SALE SALE2222Node
7777 7777FINANCE FINANCE1111Node
8888 8888FINANCE FINANCE5555Node
This script is giving output by searching in column 1 or 2 by putting exact matching word like below.
$ MYSH 6666
6666 6666SALE SALE2222Node
$ MYSH 4444AUDIT
4444 4444AUDIT AUDIT3333Node
I also need this script to provide output when there are 2-3 or any matching characters also in column 2 like below.
Expected output-
$ MYSH 4444AU
4444 4444AUDIT AUDIT3333Node
OR
MYSH 7777FINAN
7777 7777FINANCE FINANCE1111Node
arg="${arg//\\/\\\\}"
does but why are you doing it? There's nothing in your question to suggest you need it and if you do need it then there's probabl a better solutiyon to whatever problem you're trying to solve by using it. – Ed Morton Apr 23 '23 at 11:32