Re: Word-boundary mawk Debian Stretch
On 10/14/2018 1:55 PM, Étienne Mollier wrote:
>
>
> On 10/14/18 1:47 PM, john doe wrote:
>> Thank you, I was hoping for something with less pipes redirection but
>> given that portability is required, I might as wel go that way! :)
>
> Sure, one less:
>
> $ pattern=try grep -A1 -E "\<${pattern}\>" | mawk '{getline;print $2;exit}'
> (in) noise
> (in) Host try
> (in) IdentityFile ~/.ssh/try/id_rsa1
> (in) noise
> (in) Host try
> (in) IdentityFile ~/.ssh/try/id_rsa2
> (in) noise
> (out) ~/.ssh/try/id_rsa1
>
> and it should work as expected, this time. :-)
>
It is indeed, thank you.
Here's what I've come up with:
$ grep -A1 -E "\<${1}\>" ~/.ssh/config| awk '{getline;print $2;exit}'
Argument 1 ('${1}') is used because it is in a shell script/function.
--
John Doe
Reply to: