Reputation: 257
I am looking for a more efficient to use the following string to get the desired result as a one liner
date -d @1381219358 | sed 's/\ \ /\ /g' | sed 's/[:\ ]/-/g' | sed 's/2013/13/' | awk -F '-' '{print $4"-"$5"-"$6"-"$2"-"$3"-"$8}'
The desired result output is as follows:
04-02-38-Oct-8-13
Any help would be appreciated
Upvotes: 0
Views: 103
Reputation: 123608
I'm not sure if you need sed
or awk
for this. You can format the output using date
.
Try saying:
date -d @1381219358 +%H-%M-%S-%b-%d-%y
Upvotes: 2
Reputation: 41460
You can format the output directly, like this:
date -d @1381219358 +"%H-%M-%S-%b-%d-%y"
10-02-38-Oct-08-13
Upvotes: 4