General Question

rexpresso's avatar

In a *nix shell how can I touch a file naming it with the system's current UNIX timestamp?

Asked by rexpresso (922points) November 14th, 2010

I want to do a slightly more complex command, but from you I would just like enough help so I can issue a command like this:

$timestamp = unix_timestamp; touch $timestamp

Of course I’m such a newbie that obviously I’m wrong in this command. But I think you get my idea. Any help is precious!

Thanks!

Observing members: 0 Composing members: 0

2 Answers

sferik's avatar

touch `date +%s`

Backticks (on the same key as the tilde, next to 1/!) are really powerful. They work by evaling the contained command and then substituting the output.

You can do just about anything on the shell in a single line using backticks, pipes, and xargs.

Learn ‘em, love ‘em.

rexpresso's avatar

Absolutely fantastic! Thanks @sferik

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther