[Cialug] Regex Question

Nicolai nicolai-cialug at chocolatine.org
Thu Jul 28 19:46:24 UTC 2022


On Mon, Jul 25, 2022 at 11:14:54AM -0400, Todd Walton wrote:
> Let's say I have a block of text like this:
> 
> ===================================
>             {
>                 "altGrAliasing": true,
>                 "antialiasingMode": "grayscale",
>                 "closeOnExit": "graceful",
>                 "colorScheme": "Campbell",
>                 "commandline":
> "C:\\Users\\seven\\AppData\\Roaming\\Scoop\\apps\\msys2\\current\\msys2_shell.cmd
> -defterm -here -no-start -msys",
>                 "cursorShape": "bar",
>             },
> ===================================
> 
> How do I write a regex to match all lines *except* the "commandline" line?

In addition to jq and grep -v, you can do

awk '{if($1!="\"commandline\":") print}' blah.txt

It's useful in a lot of situations.

Nicolai


More information about the Cialug mailing list