Suppose you have a string like 2012-01-06 14:38:36 and you want to get only the date part of it... then try the following simply date command
VAR="2012-01-06 14:38:36"
VAR=`date +%Y-%m-%d -d "$VAR"`
echo $VAR
This will convert the string to only date and output:
2012-01-06
No comments:
Post a Comment