If your date string is stored in a variable, then you don't need to run an external program like cut
, awk
or sed
, because modern shells like bash
can perform string manipulation directly which is more efficient.
For example, in bash:
$ s="1/10/2013 23:41"
$ echo "${s% *}"
1/10/2013