Issue
I am trying to fetch a line with the following information -a string1 -b file1.txt -c string3
using grep.
I tried
grep -v grep | grep '[b][:space:] *.txt *[c]'
grep -v grep | grep '[b] *.txt *[c]'
string1, string3 and file1 are variables. So I am looking for solutions using wild characters.
But there is nothing returned. Any help will be appreciated.
Solution
You may use this grep
:
grep -- '-a [^[:blank:]]* -b [^[:blank:]]*.txt -c [^[:blank:]]*' *.txt
[^[:blank:]]
matches any non-whitespace character.--
separates options and pattern arguments.
Answered By - anubhava Answer Checked By - Marie Seifert (WPSolving Admin)