a small piece awk code chop a chunk text from input
---------------------------------------------------
#!/usr/bin/gawk -f
## Usage:
##
## filter.gawk --assign startsWith=%PDF- endsWith=%EOF inputfile
##
## OR
##
## filter.gawk --assign startsWith=ZHDASCRA55 endsWith=ZTRENDRA55 inputfile
##
BEGIN {
while (getline aline) {
if (index (aline, startsWith)) {
printf "%s\n", aline
while (getline anotherline) {
printf "%s\n", anotherline
if (index (anotherline, endsWith)) {
exit
}
}
}
}
}
--
Terrence Miao
Independent IT Consultant ... __o
Intelligent Business Solutions & Services Pty. Ltd. ... -\<,
URL: http://www.terrencemiao.com/ ... (_)/(_) ..
|