How can i grep a nearer word from a file ?
E.g
04-02-2010 Workingday
05-02-2010 Workingday
06-02-2010 Workingday
07-02-2010 Holiday
08-02-2010 Workingday
09-02-2010 Workingday
I stored above data in a file 'feb2010',
By this commend i stored date in one variable date=date '+%d-%m-%Y'
if date is 06-02-2010 , i want to grep "06-02-2010" with Workingday
and want to store the string "Workingday" in a variable
How can i do this ?
Is there any other option ?
Do you mean something like that?
This greps for your
$DATE
and selects the second column for the output via awk and stores this output in the variable$DAY
.month = " 06-02-2010 Workingday " && grep search-string $month
Try
This question doesn't post an OS so here's how you would do this under windows powershell:
Select-string is grep's equivalent