That's strange. With a directory contents of 2017-11-16, for me it yields
and not -22. Are there other files (NOT directories)?
Note that if israr75 ran the above date command in the directory containing Test1 (instead of in directory Test1) and there aren't any matching files there, there will be a diagnostic message saying no matching files found from ls written to stderr and nothing written to stdout, the tail will return no output, and the date -d option argument will just be +1day instead of something like 2017-11-16+1day.
One might guess that a cd Test1 at the start of the script might solve the problem, but this is just wild conjecture.
Quote:
Originally Posted by Peasant
Have you considered ksh93 shell builtin printf date options ?
I have found that to be quite portable across operating systems.
Relaying on GNU date is worst then relaying on ksh93 in my opinion
Regards
Peasant
My preferred shell is also ksh. It is frequently faster than bash, can handle floating point expressions in addition to handling integer expressions in arithmetic commands and arithmetic expressions, has associative and indexed arrays (associative arrays came later in bash and are declared differently than in ksh), and always runs the last element of a pipeline in the current shell execution environment (available as a settable option in recent bash 4.x). But:
isn't available in all versions of ksh. It is at least present in ksh 93u+ and later versions, but I'm not sure when it first appeared. It was not in the original ksh93 releases. And, like GNU date, ksh93 isn't generally available on some systems (Solaris 10, doesn't have GNU date or ksh93 by default).
This is why it is so crucial for the first post in each thread in these forums to tell us what operating system (including version) and shell (including version) is being used. In this thread, where we know that the OS is Red Hat release 6.2, GNU date should be readily available (and its use didn't give diagnostics about -d being an unrecognized option).
Portable, in ways as ksh93 could be easily installed anywhere.
While gnu date would require much more effort and disk space.
So if i had a date manipulation requirement in script across a multiverse of unixes, i would go with ksh.
It's the closest one can get regarding dates and shell at minimum requirements on modern systems.
Of course, not including full blown scripts or external utilities (awk, perl, python..) to handle date manipulations.
hi all,
i would like to increment the date variable i am using
for((i=20190731;i<=20190801;i++))
do
done
after 20190731 it should be 20190801 but this taking as 20190732,20190733....
kindly help me to solve this (3 Replies)
hey guys,
I need to incerement the date variable for instance
echo `date '+%F %H:%M:00'`
this produces
2014-08-02 20:05:00
-I will grant this to : $Datehour and need to assign 1 hr from now to $Datelasthour
-the script time will be used to talk to DB system information.
however... (4 Replies)
Hi all,
I need to increment date at run time.
Example:
I need to write a shell script with two parameters.
1. country code like (US,UK, IND.....)
2. Date range from_date to to_date (20070101 to 20070331)
I need to run shell script like this
country_info.sh US 20070101 20070331
... (3 Replies)
hi experts,
my requirement is like this i need to develop a shell script to update date part with new incremental date time in file some 'X' which is kept at some server location incrementing every two hours.as i am new to this scripting i need support from u people,thanx in advance (1 Reply)
hi Friends,
Today_Dt=`date "+%Y-%m-%d"`
So the Today date is 2010-05-03
I have a file which has date values as below
2010-04-27
2010-04-02
2010-04-18
2010-04-28
2010-04-29
.. (1 Reply)
Hi,
I have a variable lets say DATA_DATE.
I have to pass some value to this variable in YYYYMMDD format.
lets say today I have passed this variable as :
DATA_DATE=20100107
Then pls help me how to calculate another variable DATA_DATE1 (which is DATA_DATE+1).
The code should work... (3 Replies)
Hi,
Iam new to scripting language.:o
can someone help me out solving this thread?hopingly ya....:)
I want to write a script which connects to db and searches the count in a table which has date column and id column.
If the count is not equal to 0 then it should increment the date with the one... (4 Replies)
I need to increment a date value through shell script.
Input value consist of start date and end date in DATE format of unix.
For eg.
I need increment a date value of 1/1/09 to 31/12/09 i.e for a whole yr.
The output must look like
1/1/09
2/2/09
.
.
.
31/1/09
.
.
1/2/09
.
28/2/09... (1 Reply)
Assume, I created one file three years back and I like to move the file to some other directory with the old date (Creation date)? Is it possible? Explain? (1 Reply)