Gentoo Archives: gentoo-user

From: Stroller <stroller@××××××××××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] bash date puzzle
Date: Mon, 14 Nov 2011 20:06:04
Message-Id: 66156980-6127-4ECE-8B22-AE121515C7A1@stellar.eclipse.co.uk
In Reply to: [gentoo-user] bash date puzzle by Philip Webb
1 On 14 November 2011, at 07:06, Philip Webb wrote:
2
3 > To convert a UNIX date to a human-readable version the command is :
4 >
5 > 556: ~> date -d @1321251520
6 > Mon Nov 14 01:18:40 EST 2011
7 >
8 > I would like to create a Bash alias or function to do this,
9 > but can't get the Bash syntax right: it keeps telling me
10 > "date: the argument `1321251520' lacks a leading `+';
11
12 ~ $ function foo {
13 > date -d @$1
14 > }
15 ~ $ foo 1321251520
16 Mon Nov 14 06:18:40 GMT 2011
17 ~ $
18
19 Copied and pasted literally from my terminal, which is why you see the ">" PS2 continuation prompt on lines 2 & 3.
20
21 Stroller.