I did the following function:
#!/bin/bash
function calc_date(){
odate=$1
op=$2
days=$3
echo $(date "--date=$odate $op $days day" +%d%m%y)
}
And if I call it like this:
mydate=$(calc_date '2014-02-22' '+' '2')
echo "$mydate"
Returns:
240214
Now I'm trying to get the same output calling the function by this way:
mydate=$(calc_date '220214' '+' '2')
echo "$mydate"
How could I format the date passed as parameter to the function to ddmmyy format?
The clearest solution:
Example:
Result: