My shell script:
#!/bin/bash
echo "$1";
startd=$(date -d "$1" +"%Y%m%d");
echo "$startd";
My command:
sudo ./test.sh "20151010"
The output:
20151010
20150213
it printed todays date instead of printing the input date any idea?
My shell script:
My command:
The output:
it printed todays date instead of printing the input date any idea? |
|||
The OS X version of
The
Here's a transcript:
|
|||||
|
If you are trying to format date on OS X, you can try this:
I get the following output:
|
|||
|
date
under Linux. You may need to install the GNU Coreutils and usedate
from them. BTW, you do not needsudo
. – vinc17 Feb 13 at 23:15date
doesn't parse arbitrary date formats like the GNU version does. – Barmar Feb 13 at 23:23