I want to grep variable pattern which is in first column.
$ cat test.txt
abc.xyz
abc.def
pqr.tap
pqr.abc
abc.mnp
mnp.abc
abc.pqr
abc.mob
If variable pattern is abc
then output should be
abc.xyz
abc.def
abc.mnp
abc.pqr
abc.mob
If variable pattern is mnp
then output should be
mnp.abc
If pattern is not variable then I can do by command (For pattern mnp)
awk -F"." '{ if($1 == "mnp") print $0;}' test.txt
grep '^abc'
orawk '/^abc/'
– Stephen Rauch Feb 23 '17 at 14:32