help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Remove comment characters at start of line


From: alex xmb ratchev
Subject: Re: Remove comment characters at start of line
Date: Thu, 2 Feb 2023 09:40:02 +0100

On Thu, Feb 2, 2023, 9:31 AM Hans Lonsdale <hanslonsdale@mailfence.com>
wrote:

>
>
> I am trying to understand this sed line matching part, that is supposed to
> remove the comment characters
> at the start of the line.  The pattern is pn_ere.
>

understand regexes ,
^ from beginning
[[:space:]]* optional match space characters ( optional * , * = 'none or
more' )
then a list of the matches
begins with # for normal scripting cmds
others also
^ # comment
^ ! ...
^ @c ...
$cmt is some comment format value
..
[[:space:]]+ must match a space
..

i dunno much sed magic , but the regex is the/a key

  pn_ere="^[[:space:]]*([#;!]+|@c|${cmt})[[:space:]]+"
>
>   sed -E -n "
>     /$beg_ere/ {
>       :L1
>       n
>       /$end_ere/z
>       /$pn_ere/!z
>       s/// ; p
>       tL1
>     }
>   "
>
>
>
> --
> Sent with https://mailfence.com
> Secure and private email
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]