SunQuest
           UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old October 31st, 2003, 01:52 PM
jnau jnau is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 1 jnau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old October 31st, 2003, 03:14 PM
druuna druuna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 137 druuna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > simple grep question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway