Предполагая, что данные находятся в файле datafile
, вы можете использовать awk
для этой обработки. (Вы не можете использовать grep
, потому что он работает только с одиночными строками контекста.)
awk -F, '
# Initially we are not in a block
BEGIN { inblock=0 }
# If the third field is greater than that on the previous line, print
# it. But if we were not already in a block then print the saved line
# too - and mark that we are now in a block
NR>1 && $3>third { if (!inblock) { print line; inblock=1 } print $0 }
# If we are in a block and the third field is smaller that the previous
# line value, drop out of the block
inblock && $3<=third { inblock=0 }
# Save the values each time around
{third=$3; line=$0 }
' datafile
SomeData,SomeData,1,SomeData
SomeData,SomeData,2,SomeData
SomeData,SomeData,3,SomeData
SomeData,SomeData,1,SomeData
SomeData,SomeData,2,SomeData
SomeData,SomeData,3,SomeData
SomeData,SomeData,4,SomeData
SomeData,SomeData,5,SomeData
alias dbdate='date -d@"$( dbviewer -t Isagraf5.Resource._1.CompileDate )"'
Теперь вы можете использовать dbdate
в качестве псевдонима для
date -d@"$( dbviewer -t Isagraf5.Resource._1.CompileDate )"
. Эта команда запустит dbviewer -t Isagraf5.Resource._1. CompileDate
и вызов date
с его выводом, вставленным после @
.
$ (...)
- это подстановка команды. Он будет заменен выводом команды внутри $ (...)
.