awk:display_line_before_the_matching_string
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
awk:display_line_before_the_matching_string [2020/09/23 16:11] – created 192.168.1.1 | awk:display_line_before_the_matching_string [2021/01/06 17:08] (current) – peter | ||
---|---|---|---|
Line 4: | Line 4: | ||
awk '/ | awk '/ | ||
</ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ====== Example ====== | ||
+ | |||
+ | Assuming a file, **test.txt**, | ||
+ | |||
+ | < | ||
+ | 10 | ||
+ | 11 | ||
+ | 12 | ||
+ | 13 | ||
+ | 14 | ||
+ | 48 | ||
+ | </ | ||
+ | |||
+ | Running | ||
+ | |||
+ | <code bash> | ||
+ | awk '/ | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | Running | ||
+ | |||
+ | <code bash> | ||
+ | awk '/ | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | 10 | ||
+ | 11 | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | Row 11 has the the search string **Roux**, results in the line above, row 10, being added to the result; | ||
+ | |||
+ | Row 12 has the the search string **Roux**, results in the line above, row 11, being added to the result; | ||
+ | |||
+ | No further rows contain the search string so nothing else is added to the output. | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | Running | ||
+ | |||
+ | <code bash> | ||
+ | awk '/ | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | |||
+ | 10 | ||
+ | 12 | ||
+ | 13 | ||
+ | 14 | ||
+ | </ | ||
+ | |||
+ | ---- |
awk/display_line_before_the_matching_string.1600877500.txt.gz · Last modified: 2020/09/23 16:11 by 192.168.1.1