Try this
infile: -
123M xls <670K
234K doc >800K
dummy{
10N
}
CACHE_SIZE{
1000M
}
nawk ' /CACHE_SIZE{/{bo = 1}(/}/)&&(bo){print;exit}bo ' infile
Gives output: -
CACHE_SIZE{
1000M
}
Hope it helps
---------- Post updated at 10:17 PM ---------- Previous update was at 08:22 PM ----------
Is this what you need?
TX5XN:/home/brad/forum/claw82>cat infile
CACHE SIZE{
cache_size=1000M
}
CRONTAB{
crontab=1 12 2 10 5
}
POLITICS{
100MF doc,docx,xls <5600K 02/04/02/02/02K
55MF jpg >300M 03/03/02/03/05K
65%F mpg =000M 02/02/02/05/05M
}
TX5XN:/home/brad/forum/claw82>nawk ' /CACHE SIZE{/,/}/;/CRONTAB{/,/}/;/POLITICS{/,/}/ ' infile
CACHE SIZE{
cache_size=1000M
}
CRONTAB{
crontab=1 12 2 10 5
}
POLITICS{
100MF doc,docx,xls <5600K 02/04/02/02/02K
55MF jpg >300M 03/03/02/03/05K
65%F mpg =000M 02/02/02/05/05M
}
---------- Post updated 14-10-09 at 10:04 AM ---------- Previous update was 13-10-09 at 10:17 PM ----------
Looking at your awk script I think you probably need to edit it to something like this: -
nawk ' BEGIN {FS = "\t" print "Starting to read the config file" num=0; bucle=0;} /POLITICS{/,/}/{ print if( $0 ~ /^[0-9]*[\%|M|K|G][C|F]\t[A-Za-z|\,]*\t[\|\=][0-9]*[K|M|G]\t[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][M|K|G]$/ ) { print "Instructions for politics" }} /CACHE SIZE{/,/}/{ print if($0 ~ /^cache_size=[0-9]*[K|M|G]/ ) { print "Instructions for cache size" }} /CRONTAB{/,/}/{ print if( $0 ~ /crontab=[0-9]*|\*\t[0-9]*|\*\t[0-9]*|\*\t[0-9]*|\*\t[0-9]*|\*/ ) { print "Instructions for crontab" }} ' infile
This gives the output: -
Starting to read the config fileCACHE SIZE{cache_size=1000MInstructions for cache size}CRONTAB{crontab=1 12 2 10 5Instructions for crontab}POLITICS{100MF doc,docx,xls 300M 03/03/02/03/05K65%F mpg =000M 02/02/02/05/05M}
Hope that looks ok I cannot get the web form to enter the code tags for me so am doing them from memory.Please note that your pattern for the POLITICS stuff does not seem to work.Cheers
---------- Post updated at 10:07 AM ---------- Previous update was at 10:04 AM ----------
I can't get the formating to work, will have to wait till I get home tonight before I can post this properly.