Am flustered up with date... interesting what I had used to work in Fedora 4 and now with a system update to fedora 10 it doesn't and really not sure why?
I assign a variable: date_log=`date -d '1 day ago' +"%h %e"` which is for a specific system log that uses dates in format "Feb 5" losing the leading 0's. So I used this for about 2 years on fedora 4 by setting up log collections for last 10 days using the string format assigned to a variable, passed that to a function and grep'd out some stuff by day.
Now with fedora 10 bash strips the leading extra space after it puts it in the variable.
This works: foo=`date +"%h %e"` foo shows "Feb 5" with two spaces
this does not: foo=`date -d '1 day ago' +"%h %e"` foo shows "Feb 5" with one space. I can type the same date command at CLI and it shows two spaces. Interesting it worked fine in fedora 4??
Actual code truncated:
Get data simply greps out some dates such as:
Really confused why the space is now truncated.
I tried assigning the variable in quotes like date="$(date -d '1 day ago' +"%h %e")"
Tried using %b %_d as the format.
I can always get date to respond properly with appropriate formatting, but once I shove it into a variable the space goes away.
Idea's?
Thanks a bunch!
Last edited by Franklin52; 02-06-2013 at 06:18 AM..
Reason: Please use code tags for data and code samples
As pointed out by Franklin52 when he edited your original post for you: it is imperative that you use [code] and [/code] tags around any posted data or code. This stops things like double spaces line indents and such from being changed by the forum.
I'm guessing here that you meant that the echo has additional space between month and day but grep is still not finding the text. Can you post the actual grep statement you used and the data this it didn't match, using the code tags shown above.
This User Gave Thanks to Chubler_XL For This Post:
Thanks for the code tag. So long story short I got it working and it was an idiotic fault. My system logs had no data on a few days I was trying which of course meant it failed as the grep had no data.
Hello All,
we what we call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below:
abc.txt
------------------
line1
line2
line3
$$EDWS_DATE_INSERT=08-27-2019
line4
$$EDWS_PREV_DATE_INSERT=08-26-2019
I am trying to... (1 Reply)
I am not able to pass date stored in a variable as an argument to date command. I get current date value for from_date and to_date
#!/usr/bin/ksh
set -x
for s in server ; do
ssh -T $s <<-EOF
from_date="12-Jan-2015 12:02:09"
to_date="24-Jan-2015 13:02:09"
echo \$from_date
echo... (7 Replies)
Hi All,
I am trying to add one day to the busdt variable i am extracting from a file (DynamicParam.env). I am deriving the busdt as below.
Is there any function which I can use to derive as below.
If busdt=20120910, then the new derived variable value should be 20120911
If... (2 Replies)
Is there date variable in bash?
for example, I have string 01-23-2010 (mm-dd-yyyy) or 23-01-2010 (dd-mm-yyyy).
How can I convert that string to date variable?
and how to do some math operation based on date?
for example, today is 12-11-2010.
I want to know date 100 days after today or 50... (3 Replies)
Hi folks,
I need to write a script that should activate a process according to the current hour.
The process should be activatet only if the hour is between midnight (00:00) and 07:00.
How should I create the condition?
Thanks in advance,
Nir (2 Replies)
Hello:
I have a script that requires the use of DOY (as a variable) instead of YY/MM/DD. I already obtained these parameters from downloaded files and stored them as variables (i.e. $day, $month, $year).
Is there any simple script that I could incorporate in mine to do this job?
Regards,
... (8 Replies)
Hi,
Another nubie to Unix programming.
I am using the Korne shell.
I am trying to use the system date as a name in a tar file. Here is the code to explain.
TODAY= date +%m%d%y
echo $TODAY ### it echo's 021606 which is fine
tar -cvf "$TODAY".tar *.std*
I think you get the idea.... (11 Replies)