regex - Awk only match first match of line in multiline text -
I have a specific number ( I tried: Correct output: About: The main point by default Looking at one of your input lines: I have changed your As a note, Finally, @jedar said as follows: "All this can be reduced:" 06:00 ) and (
9:00 ) If this is the first match on a line in a multi-line file, the problem is that the awk about my limited knowledge is that I either get only the first match, or even the second number also matches I would also like to match the counting and ending of the resulting matches, but since it does not match correctly, I have not yet met.
in the schedule & lt; 06: 00>: 12 lieutenant; Written in 0: 06: 00; 08: 00 & gt; 10 out of & lt; 06: 00 & gt ;: 0; 06: 00 & gt ;: 09 Out & lt; 05: 00 & gt ;: 0 in the schedule & lt; 07: 00 & gt ;: 13 out & lt; Schedule: 08: 00 & gt;: 0; 06: 00>: 12 out of & lt; 09: 00 & gt ;: 0; 09: 00 & gt ;: 12 Out & lt; Written in 0: 06: 00; 07: 00>: 11 out of & lt; 06: 00 & gt ;:
awk '/ 06 / || / 09 / 'schedule.txt awk' $ 1 ~ / \ & lt; 06 / || / \ & Lt; 09 / {print $ 1} 'schedule.txt
06: 00> 12 out & lt; 06: 00 & gt ;: Schedule in 0; 06: 00 & gt ;: 9 outside & lt; 05: 00 & gt ;: 0 schedule lieutenant; 06: 00 & gt; 12 out & lt; 09: 00 & gt;: 0: 09: 00 & gt ;: 12 Out & lt; 06: 00 & gt ;: 4 4 matches
awk '$ 3 ~ / & lt; 06 / || / & Lt; 09 / {print $ 0} 'schedule.txt # ^ ^
awk to string each string Is in the
$ 2 in words separated from spaces and so on. The complete line is
$ 0 .
in the schedule & lt; 06: 00 & gt ;: 12 Out & lt; 06: 00 & gt;: 0 & lt; ------ & gt; & Lt; & Gt; & Lt; -------- & gt; & Lt; - & gt; & Lt; ------- & gt; $ 1 $ 2 $ 3 $ 4 $ 5 & lt; ------------------------------ & gt; $ 0
awk program to test
$ 3 which appears to be the correct field and matches In the case of, I print the entire line (
$ 0 ).
print $ 0 can be minimized
print . Many orders / tasks that accept the string with some more "frills" in
awk
$ 0
sh $ awk '$ 3 ~ / & lt; 06 / || / & Lt; 09 / {count ++; Print $ 0} END {printf ("% d total match \ n", counting)} 'in schedule.txt & lt; 06: 00 & gt ;: 12 Out & lt; 06: 00 & gt ;: 0; 06: 00 & gt; : 9 out of & lt; Schedule: 0: 00: 0; 06: 00>: 12 out of & lt; 09: 00 & gt ;: 0; 09: 00 & gt; 12 & amp; 0 06: 00 & gt; Altogether,
awk 'END {print X, "total match"} $ 3 ~ / 0 [6 9]: / & amp; ++ x '
Comments
Post a Comment