
October 31st, 2003, 03:14 PM
|
|
Contributing User
|
|
Join Date: Sep 2003
Posts: 137
Time spent in forums: 5 m 37 sec
Reputation Power: 0
|
|
|
Re: simple grep question
Quote: Originally posted by jnau
#!/bin/sh
date +"%b %d" > $dt
grep $dt /var/adm/syslog/syslog.log
|
The date format is incorrect, plus sign should be within the double quotes:
-> date"+%b %d"
If you want to fill a variable (dt) use the = sign. If you use > the shell thinks that you want to redirect it to a file represented by the variable $dt
dt = `date"+%b %d"`
The backqoutes around the complete date command are important.
Code:
#!/bin/sh
dt = `date "+%b %d"`
grep $dt /var/adm/syslog/syslog.log
Those 2 lines can be put together:
Code:
#!/bin/sh
grep `date "+%y%m%d"` /var/adm/syslog/syslog.log
|