Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #201213
| From | john doe <johndoe65534@mail.com> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Word-boundary mawk Debian Stretch |
| Date | 2018-10-14 13:50 +0200 |
| Message-ID | <wIN4e-1S0-9@gated-at.bofh.it> (permalink) |
| References | <wIJMZ-8uZ-1@gated-at.bofh.it> <wIMKS-1LW-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 10/14/2018 1:24 PM, Étienne Mollier wrote:
> John Doe, on 2018-10-14:
>> Hi,
>
> Good Day,
>
>> With gawk I'm able to do the following:
>>
>> $ gawk -v pattern=try '$0 ~ "\\<"pattern"\\>"{getline;print $2}'
>> ~/.ssh/config
>> ~/.ssh/try/id_rsa
>>
>> $ cat ~/.ssh/config
>> Host try
>> IdentityFile ~/.ssh/try/id_rsa
>>
>> I don't want to install extra pkgs on Debian Stretch (9).
>> Googling around didn't turn out something useful.
>>
>> Does anyone has any idea on how I can emulate the above using
>> mawk?
>
> No idea how to use mawk to emulate the behavior you describe; it
> is far from being gawk. However you can refine something
> looking like that, to /not/ make use of gawk:
>
> pattern=try
> grep -A1 -E "\<${pattern}\>" \
> | tail -n-1 \
> | mawk '{print $2}'
>
> I get the following, if this is what you expect:
>
> $ pattern=try grep -A1 -E "\<${pattern}\>" | tail -n-1 | mawk '{print $2}'
> Host try
> IdentityFile ~/.ssh/try/id_rsa^D
> ~/.ssh/try/id_rsa
>
> Feels a bit like Wily the coyote maybe, I'm pretty much certain
> it can be done simpler... :-)
>
Thank you, I was hoping for something with less pipes redirection but
given that portability is required, I might as wel go that way! :)
--
John Doe
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Word-boundary mawk Debian Stretch john doe <johndoe65534@mail.com> - 2018-10-14 10:20 +0200
Re: Word-boundary mawk Debian Stretch Étienne Mollier <etienne.mollier@mailoo.org> - 2018-10-14 13:30 +0200
Re: Word-boundary mawk Debian Stretch john doe <johndoe65534@mail.com> - 2018-10-14 13:50 +0200
Re: Word-boundary mawk Debian Stretch Étienne Mollier <etienne.mollier@mailoo.org> - 2018-10-14 14:00 +0200
Re: Word-boundary mawk Debian Stretch john doe <johndoe65534@mail.com> - 2018-10-15 13:40 +0200
Re: Word-boundary mawk Debian Stretch john doe <johndoe65534@mail.com> - 2018-10-14 13:50 +0200
csiph-web