|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
simple grep question
I need to get the present month and day and grep the syslog.log file to get the days events.
i have tried the following: #!/bin/sh date +"%b %d" > $dt grep $dt /var/adm/syslog/syslog.log sorry it is so basic but I'm just starting to use unix. thanks |
|
#2
|
|||
|
|||
|
Re: simple grep question
Quote:
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 |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > simple grep question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|