This script counts one by one every time the user runs the script. “./scriptname reset” reset the counter.


!/bin/bash
if [ "$1" = "reset" ]
then
rm -rf fstore
fi
sayi=0
if [ -f fstore ]
then
sayi=`cat fstore`
fi
let sayi=$sayi+1
echo "INCREMENTING"
echo $sayi > fstore
echo -e -n "CURRENT="
echo $sayi

uses fstore file to remember the previous number.

Buy me a beer

Related posts:

  1. Shell script to check file & directory existance if [ -f filename ] then echo "file exist" else...
  2. Automount ntfs paritions as read/write This will show you how to automount your root Window’s...
  3. 1 PC 2 Ethernet port and 1 PC one ethernet port and first PC as a gateway Needed program: Iptables PC 1 system gateway = 192.168.2.1 (eth1)...
  4. linux watch command & example usage you can use watch command directly like this watch –interval=1...