Comments on: Shell scripting – updating a file holding a counter https://ben.akrin.com/shell-scripting-updating-a-file-holding-a-counter/ Tue, 11 Jun 2013 00:44:02 +0000 hourly 1 https://wordpress.org/?v=7.1 By: Ben https://ben.akrin.com/shell-scripting-updating-a-file-holding-a-counter/#comment-396 Tue, 11 Jun 2013 00:44:02 +0000 http://ben.akrin.com/?p=1222#comment-396 In reply to PL.

It’s true bc is not always there to help. Thanks for your contribution & dropping a “thx”!

]]>
By: PL https://ben.akrin.com/shell-scripting-updating-a-file-holding-a-counter/#comment-395 Mon, 10 Jun 2013 14:34:18 +0000 http://ben.akrin.com/?p=1222#comment-395 Since we’re dealing with integers, I would rather write:
f=/tmp/counter; n=`cat $f | xargs expr 1 +`; echo $n > $f

No need for bc this way. But you still need a variable though :/

ps: thx for this blog, some articles really helped me

]]>
By: Ben https://ben.akrin.com/shell-scripting-updating-a-file-holding-a-counter/#comment-394 Mon, 04 Feb 2013 16:13:43 +0000 http://ben.akrin.com/?p=1222#comment-394 In reply to thomas.

I’m pretty unclear with what’s going on exactly there, care to explain?

]]>
By: thomas https://ben.akrin.com/shell-scripting-updating-a-file-holding-a-counter/#comment-393 Mon, 04 Feb 2013 14:07:30 +0000 http://ben.akrin.com/?p=1222#comment-393 # echo 2 > /tmp/counter
# echo $(($(cat /tmp/counter)+3))

]]>