Unix/Linux Go Back    



Keeping padding in a date field

Shell Programming and Scripting




Kindly Note - This is a Single User Post by Forum Member cfajohnson Regarding:
Keeping padding in a date field.
Please Follow The Primary Link Above to View the Full Discussion.

   
Old Unix and Linux 01-12-2009
cfajohnson's Unix or Linux Image
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
 
Join Date: Mar 2007
Last Activity: 11 July 2016, 2:55 PM EDT
Location: Toronto, Canada
Posts: 2,898
Thanks: 0
Thanked 134 Times in 118 Posts
Quote:
Originally Posted by seanbyrne View Post
Still having a problem though, i'm plugging the variable into a sed command and its still not padding the %e variable:


Code:
CURRENT_DATE="$(date +"%a %b %e")"

sed -n '/^"$CURRENT_DATE"/,$ p' /var/sean/errorlog.log > /tmp/tempfile.tmp


You are not plugging the variable into the sed command; you are giving it a literal string because it is within single quotes.


Code:
CURRENT_DATE=$(date +"%a %b %e")
sed -n "/^$CURRENT_DATE/,$ p" /var/sean/errorlog.log > /tmp/tempfile.tmp