0

Am quite new in the Unix field and I am currently trying to extract data set from a text file. I tried with sed, grep, awk but it seems to only work with extracting lines, but I want to extract an entire dataset... Here is an example of file from which I'd like to extract the 2 data sets (figures after the lines "R.Time Intensity")

[Header]
Application Name    LabSolutions
Version 5.87
Data File Name  C:\LabSolutions\Data\Antoine\170921_AC_FluoSpectra\069_WT3a derivatized lignin LiCl 430_GPC_FOREVER_430_049.lcd
Output Date 2017-10-12
Output Time 12:07:32

[Configuration]
Instrument Name BOTAN127-Instrument1
Instrument #    1
Line #  1
# of Detectors  3
Detector ID Detector A  Detector B  PDA
Detector Name   Detector A  Detector B  PDA
# of Channels   1   1   2

[LC Chromatogram(Detector A-Ch1)]
Interval(msec)  500
# of Points 9603
Start Time(min) 0,000
End Time(min)   80,017
Intensity Units mV
Intensity Multiplier    0,001
Ex. Wavelength(nm)  405
Em. Wavelength(nm)  430
R.Time (min)    Intensity
0,00000 -709779
0,00833 -709779
0,01667 17
0,02500 3
0,03333 7
0,04167 19
0,05000 9
0,05833 5
0,06667 2
0,07500 24
0,08333 48

[LC Chromatogram(Detector B-Ch1)]
Interval(msec)  500
# of Points 9603
Start Time(min) 0,000
End Time(min)   80,017
Intensity Units mV
Intensity Multiplier    0,001
R.Time (min)    Intensity
0,00000 149
0,00833 149
0,01667 -1

I would greatly appreciate any idea. Thanks in advance. Antoine

Antoine C
  • 5
  • 2
  • add expected output to question as well as at least one of the command you tried... I think this Q&A will help to solve it by yourself https://stackoverflow.com/questions/17908555/printing-with-sed-or-awk-a-line-following-a-matching-pattern – Sundeep Oct 16 '17 at 08:42
  • or perhaps as easy as https://stackoverflow.com/questions/38972736/how-to-select-lines-between-two-patterns – Sundeep Oct 16 '17 at 08:43

3 Answers3

0
 awk '/R.Time/,/LC/' file|grep -v -E "R.Time|LC"

grep part will remove the R.Time and LC lines that come as a part of the output from awk

abhishek phukan
  • 751
  • 1
  • 5
  • 16
0
awk '/^[^0-9]/&&d{d=0} /R.Time/{d=1}d' file

Brief explanation,

  • Set d as a flag to determine print line or not
  • /^[^0-9]/&&d{d=0}: if regex ^[^0-9] matched && d==1, disabled d
  • /R.Time/{d=1}: if string "R.Time" searched, enabled d
CWLiu
  • 3,913
  • 1
  • 10
  • 14
0

I think it's a job for sed.

sed '/R.Time/!d;:A;N;/\n$/!bA' infile
ctac_
  • 2,413
  • 2
  • 7
  • 17