0

I would like to loop through several log files and print the last few lines from each of them to the terminal. I tried using tail but it prints the last 10 lines and what I need is sometimes more and sometimes less. Is it possible to print the content only after matching a certain word or expression?

for example my file content is similar to this

# AllowDiag:         1
# NClusters          8
# FWHM        8.713072
# dLh         0.055835
# Cluster   Size(n)   Size(mm^3)     MNIX   MNIY    MNIZ      Max     GRFCWP
  1        106       7008.0     -1.00  -3.00  -5.00          -7.59855  0.000000
  3         18       104.0      0.00  -6.00   7.00          -6.64596  0.000000
  4          5       40.0      3.00   2.00  -3.00          -5.03464  0.000003
  5          22        6.0      1.00  -4.00  -1.00          -8.14191  0.004308
  6          20        10.0     -2.00   2.00  -3.00          -4.74390  0.006120
  7          19        2.0     54.00   36.00  10.0          -5.35168  0.008492
  8          18        10.0     92.00  -134.00  -23.00       -6.59801  0.015152

and I want to print the lines after and including # Cluster

Ilkay Isik
  • 203
  • 4
  • 14

1 Answers1

1

You can do sed -n '/YOUR PATTERN HERE/,$p' FILE. The will print from the line matching your pattern to the end of the file.

Matt Shin
  • 424
  • 2
  • 7