How can I use grep, sed, awk, or other Linux tool or bash script to search each line of a file for the sequence “\t$month\t$day\n”, where…
\t = tab
\n = new line
$month = Sep #$month is a variable with the content “Sep”
$day = 4 #$day is a variable with the content “4”?
Using grep, I can find \t, \n, $month, and $day individually, but to reduce false positives, I want the tool(s) to search each line of the file for the combination “\t$month\t$day\n”, and upon a match, send the line(s) to standard output, i.e., the console.
How can I search for the combination “\t$month\t$day\n” per line of the file, and have the tool output each matching line to the console?
Example: Here are the contents of the file “start-with-core”
$ cat start-with-core
core4321 Sep 3
core.1234 Nov 4
core4 Sep 4
core10 Sep 4
core11 Nov 4
core44 Sep 2
core400 Sep 3
There is one tab after the first field (column), one tab after the second, and a new line character after the third.
$ echo $month
Sep
$ echo $day
4
$ grep $'\n' start-with-core
core4321 Sep 3
core.1234 Nov 4
core4 Sep 4
core10 Sep 4
core11 Nov 4
core44 Sep 2
core400 Sep 3
$ grep $'\t' start-with-core
core4321 Sep 3
core.1234 Nov 4
core4 Sep 4
core10 Sep 4
core11 Nov 4
core44 Sep 2
core400 Sep 3
$ grep "$month" start-with-core
core4321 Sep 3
core4 Sep 4
core10 Sep 4
core44 Sep 2
core400 Sep 3
$ grep "$day" start-with-core
core4321 Sep 3
core.1234 Nov 4
core4 Sep 4
core10 Sep 4
core11 Nov 4
core44 Sep 2
core400 Sep 3
Any ideas? Thanks! Estudiante
///\\