Ok, I am trying to find two sets of strings in files created today, within directories that contain a specific string in their name. I have tried different variations of grep and find without the exact results I need. I'll elaborate:
We have numerous devices made by the same vendor, but there are three different models. These devices are in 38 states, with multiple devices in each state. We have used this information to create hostnames for these devices. Here's and example of the format:
rbflftmy81
vendor code = rb
state = fl
city = ftmy
model = SE-800 (hence the "8")
device number = #1 (hence the "1"; subsequent devices in the same city and state would have a 2, or 3, etc.)
These devices get backed up every day, each respective device backing up into its own folder, at it's own time, but the same time each day. The node name and the year, date, and time it backed up are all part of the file name that it backs up to. The directory structure looks like this:
/home/dsl/configs/dslftmyrb--rbflftmy81/dslftmyrb--rbflftmy81.201109271001.config
/home/dsl/configs/dslftmyrb--rbflftmy81/dslftmyrb--rbflftmy81.201109281001.config
I basically need to execute a "grep -A 1" for the strings "port ethernet" and "port atm" on any file created on today's date in any directory with "rb" and "8" in the directory or file name, so I can get all of the strings similar to these:
port atm 6/1
description NF,Ingress,95.MHAZ.784569..UFLG,M4FLFTMYXA01,3B2,622Mb
port ethernet 10/1
description NF,Egress,95.LUXZ.457896..UFLG,A7FTMYFLXA38W,1/1/8,1Gb
I was trying this:
Code:
grep -R -A 1 -e "port ethernet" -e "port atm" /home/configs/dsl/dsl*/dsl*rb*8*.config
...but it doesn't like wildcarding on the directory name.
I also tried this:
Code:
find . -name \*.config | xargs grep rb*8* | grep -A 1 -e "port ethernet" -e "port atm"
But it doesn't work either. Does anyone know how to do this? Moreover, how would I get it to pull files only from today? Sorry if it's wordy and complicated. Thanks in advance!