mirror of
https://github.com/chubin/cheat.sheets
synced 2024-11-12 19:10:26 +00:00
Add: awk paragraph search, separated output
This commit is contained in:
parent
a26a0ee062
commit
adfdf75cb7
@ -47,8 +47,13 @@ awk -v RS='' '
|
||||
printf '1 2 3' | awk 'BEGIN {OFS=":"}; {print $1,$2,$3}'
|
||||
|
||||
# Search paragraph for the given REGEX match.
|
||||
# Paragraphs will be collapsed together.
|
||||
awk -v RS='' '/42B/' file
|
||||
|
||||
# Search paragraph for the given REGEX match.
|
||||
# Paragraphs will be separated with a new line.
|
||||
awk -v RS= ORS='\n\n' '/42B/' file
|
||||
|
||||
# Display only first field in text taken from STDIN.
|
||||
echo 'Field_1 Field_2 Field_3' | awk '{print $1}'
|
||||
# Note that in this case, you're far better off using cut(1).
|
||||
|
Loading…
Reference in New Issue
Block a user