help-bash
[Top][All Lists]
Advanced

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

Re: Extracting sections from code files


From: Dennis Williamson
Subject: Re: Extracting sections from code files
Date: Wed, 3 Nov 2021 13:57:14 -0500

On Wed, Nov 3, 2021, 1:46 PM fatiparty--- via <help-bash@gnu.org> wrote:

>
> Nov 3, 2021, 17:39 by celvidge001@gmail.com:
>
> > On 03/11/2021 03:51 pm, fatiparty--- via wrote:
> >
> >> ## Mode: org
> >> #  Assigns shell positional parameters or changes the values of shell
> >> #  options.  The -- option assigns the positional parameters to the
> >> #  arguments of {set}, even when some of them start with an option
> >> #  prefix `-'.
> >> ## # End of org
> >>
> >> ;; Mode: org
> >> ;  Assigns shell positional parameters or changes the values of shell
> >> ;  options.  The -- option assigns the positional parameters to the
> >> ;  arguments of {set}, even when some of them start with an option
> >> ;  prefix `-'.
> >> ;; # End of org
> >>
> >> @c Mode: org
> >> @c Assigns shell positional parameters or changes the values of shell
> >> @c options.  The -- option assigns the positional parameters to the
> >> @c arguments of {set}, even when some of them start with an option
> >> @c prefix `-'.
> >> @c # End of org
> >>
> >
> > grep -v 'org$' testfile | cut -c4-
> >
> > --
> > Chris Elvidge
> > England
> >
>
> Have updated the bash function to use a single pattern charcl.  But the
> comments are not being removed.
>
> capture ()
> {
> local efile="$1"
>
> local begrec endrec charcl
>
> charcl='^[[:space:]]*([#;!]+|@c|\/\/)[[:space:]]*'
> begrec="${charcl}"'Mode: rec$'
> endrec="${charcl}"'# End of rec$'
>
> awk -v ccls="$charcl" -v bego="$begorg" -v endo="$endorg" \
>    '$0 ~ bego { found=1; next }
>     $0 ~ endo { found=0; }
>     found { sub(/ccls/,""); print }' "$efile"
> }
>
>


begrec is not begorg, etc.

>


reply via email to

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