in reply to Re: best way to keep a simple count?
in thread best way to keep a simple count?

    echo $((`cat counter` + 1)) > counter

Which won't work well if there can be multiple instances of the program running at the same time.

Replies are listed 'Best First'.
Re^3: best way to keep a simple count?
by Anonymous Monk on Apr 11, 2005 at 16:04 UTC
    I never claimed it was. And it wasn't the first suggestion in this thread that might fail if multiple instances of the program are running at the same time. (Well, technically, having multiple instances of the program running at the same time isn't the problem - the problem is them executing the one line of code at the same time).

    Code Pendants question was vague. He just wanted to know what other people used. He didn't state anything specific about his situation. Other than the implicite suggestion the program is started once a day (so, no multiple occurences).

    Here's another one-liner you can list faults for:

    perl -pi -le '$_++' counter