LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-01-2011, 01:19 AM   #1
greenpool
Member
 
Registered: Sep 2010
Posts: 41

Rep: Reputation: 0
date; how to display as i.e Oct 1 *note the extra space*


Hi,

i'm writing a script that greps the logs based on month/date.

when i found this:

Code:
Oct  1 14:41:01 ubuntu CRON[2446]: pam_unix(cron:session): session closed for user smmsp
Oct  1 14:44:55 ubuntu gnome-screensaver-dialog: gkr-pam: unlocked login keyring
Oct  1 14:58:06 ubuntu gnome-screensaver-dialog: gkr-pam: unlocked login keyring
as you can see it doesn't record the date as "Oct 01" and instead of "Oct 1" it has a a space for the 0 thus becoming "Oct 1" (double spaced)


but when the date changes to something with 2 digits like "Aug 14" its normal:

Code:
Aug 14 12:17:01 ubuntu CRON[2052]: pam_unix(cron:session): session opened for user root by (uid=0)
Aug 14 12:17:01 ubuntu CRON[2052]: pam_unix(cron:session): session closed for user root

so my static code to grep the date doesn't work. i'm using ubuntu and the logs were from /var/logs/auth.log

my code was:

Code:
SEARCHDATE=$(date +%b\ %d)

any comments on how to get this working? thnaks.
 
Old 10-01-2011, 01:41 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
From 'man date':
Quote:
%e day of month, space padded; same as %_d
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
HP Mini Note 2133 Display configuration olilogu Linux - Laptop and Netbook 3 12-16-2008 10:35 PM
Install display driver on hp 2133 mini-note alepolk Puppy 1 11-20-2008 05:46 AM
need to mount extra / space Geist3 Slackware 5 01-17-2005 09:31 PM
extra hd space? adam_boz Linux - Newbie 2 10-24-2002 03:08 AM


All times are GMT -5. The time now is 07:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration