sed

DATADUMP 100
  JOB
    DspUserName lawson
    JobName CU201TEST
    Description
    Type 1
    FilePathName
    JOBSTEP
      StepNbr 00000
      StepKey 00000
      Description Currency Codes Listing
      Type 0
      Token CU201
      ProductLine TEST
      Project TEST
      Params
      IntRptServer 0
      TranSize 0
      FilePathName
      LogTranSize
      JOBSTEPREPORT
       PrtFileName CU201.prt
        PrtFilePath D:\lsftest\law/print/lawson/cu201test/1
        DstGrp
        PrinterName

I'd like to use sed to only keep from JOB to JOBSTEPREPORT. I really appreciate any help you can provide.

Any attempts / ideas / thoughts from your side?

Hint from man sed :

my attempt:
sed -n -e 1,21p -e 4p test.log - it works, but sometimes the word "JOBSTEPREPORT" is no at 21st position.

how about for starters:

sed -n '/[ ]*JOB[ ]*/,/JOBSTEPREPORT/p' myFile

Perfect! Thank you much. Have a nice day.

That RE allows a zero-match of the surrounding spaces, so it behaves like the following

sed -n '/JOB/,/JOBSTEPREPORT/p' myFile

Anchors ^ and $ change everything: the following ensures there are only space characters before and after JOB

sed -n '/^ *JOB *$/,/JOBSTEPREPORT/p' myFile
1 Like