help-bash
[Top][All Lists]
Advanced

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

Printing sections from files with sed


From: Hans Lonsdale
Subject: Printing sections from files with sed
Date: Tue, 31 Jan 2023 07:49:02 +0100 (CET)

I want to print lines according to the following description

  ## FM [TOBIN]
  ## Some text
  ## More text
  ## END OF FM [TOBIN]

I provide 

faml="FM"
asmb="TOBIN"

Here I set the matching patterns and call sed 


      pn_ere='^[[:space:]]*([#;!]+|@c|//)[[:space:]]'
      beg_re="${pn_ere}${faml} \[${asmb}\][[:space:]]*$"
      end_re="${pn_ere}END OF ${faml} \[${asmb}\][[:space:]]*$"

      sed -n "/$beg_re/,/$end_re/ {
          /$beg_re/d ; /$end_re/z; s/${pn_ere}// ; p
        }" "$filename"

I get the error 

sed: -e expression #1, char 27: unknown command: `/'


Initially thought the problem could be that either the vars are misspelled, or 
for some
other reason one or both don't have values. 

But checking things again did not show any misspelled vars or empty values,




-- 
Sent with https://mailfence.com  
Secure and private email



reply via email to

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