tanit
1
Hi Experts,
I have files name
report_20090416
report_20090417
report_20090418
report_20090420
report_20090421
I have 2 input from user
From Date: 20090417
To Date: 20090420
and I need to grep only those line in between. Output should be
report_20090417
report_20090418
report_20090420
Thanks,
try this:
awk -F "_" -v st=20090417 -v ed=20090420 '$2 >= st && $2 <= ed{print}' filename
cheers,
Devaraj Takhellambam
Try this,
Variables i1 and i2 are inputs
$ echo $i1
20090417
$ echo $i2
20090420
$ cat file
report_20090416
report_20090417
report_20090418
report_20090420
report_20090421
$ awk -F"_" ' $2 >= '$i1' && $2 <= '$i2' {print}' file
report_20090417
report_20090418
report_20090420
tanit
4
Thank you all for your help. It works.