lnum=$(($(sed -n '/^---$/=' file | sed '$!d') +1)); sed -n "${lnum},$ p" file
The first sed
ouputs line numbers of the "---" lines...
The second sed
extracts the last number from the first sed's output...
Add 1 to that number to get the start of your "ccc" block...
The third 'sed' outputs from the start of the "ccc" block to EOF
Update (with ammended info re Gilles methods)
Well I was wondereing about how glenn jackman's tac
would perform, so I time-tested the three answers (at the time of writing)... The test file(s) each contained 1 million lines (of their own line numbers).
All answers did what was expected...
Here are the times..
Gilles sed
(single pass)
# real 0m0.470s
# user 0m0.448s
# sys 0m0.020s
Gilles awk
(single pass)
# very slow, but my data had a very large data block which awk needed to cache.
Gilles 'two-pass' (first method)
# real 0m0.048s
# user 0m0.052s
# sys 0m0.008s
Gilles 'two-pass' (second method) ... very fast
# real 0m0.204s
# user 0m0.196s
# sys 0m0.008s
Gilles 'two-pass' (third method)
# real 0m0.774s
# user 0m0.688s
# sys 0m0.012s
Gilles 'gawk' (RT method) ... very fast, but is not POSIX.
# real 0m0.221s
# user 0m0.200s
# sys 0m0.020s
glenn jackman ... very fast, but is not POSIX.
# real 0m0.022s
# user 0m0.000s
# sys 0m0.036s
fred.bear
# real 0m0.464s
# user 0m0.432s
# sys 0m0.052s
Mackie Messer
# real 0m0.856s
# user 0m0.832s
# sys 0m0.028s