egrep messagelog for two dates

Hi,

i try to (e)grep the messagelog for two dates:

xxx@yyyy:~> sudo egrep '(Apr 28|Apr 27)' /var/log/messages_mozppi2

works:

...
Apr 28 13:23:26 mozppi2 syslog-ng[1916]: STATS: dropped 0
...

but

xxx@yyyy:~> datum=$(echo \'\($(date '+%b %d')'|'$(date -d yesterday '+%b %d')\)\')
xxx@yyyy:~> echo $datum
'(Apr 28|Apr 27)'
xxx@yyyy:~> sudo egrep $datum /var/log/messages_mozppi2
egrep: �(� oder �\(� ohne schlie�ende Klammer

doesn�t

(sorry but german enviroment, it says

egrep: �(� or �\(� without closing parenthesis

I�m working in a Bash.

Thank You

Niels

Hi,

try this,

datum=$(echo \($(date '+%b %d')'|'$(date -d yesterday '+%b %d')\))
sudo egrep "$datum" file.txt

Try:

datum='['$(date '+%b %d')'|'$(date '+%b %d')']'
grep -e $datum /var/log/messages_mozppi2

Try this:

$ cat file
test
Apr 28
eheh
Apr 27

$ datum=$(echo \($(date '+%b %d')'|'$(date -d yesterday '+%b %d')\))

$ egrep "$datum" file
Apr 28
Apr 27

Cheers :wink:

so " is the trick.

thank you