[wplug] Bash scripting help - count from 1 to 4
James O'Kane
jo2y at midnightlinux.com
Sat Jan 28 17:45:12 EST 2006
On Sat, 28 Jan 2006, Gentgeen wrote:
>
> I am writing a bash script as part of my backup routine. What I need
> to keep track of is which zip disk to use, Disk 1, 2, 3, or 4.
> (rotating the disks out once a week)
I'm not sure where you're getting stuck in this problem. The reading from
file? The math? Here is something quick I came up with:
#!/bin/bash
x=`cat DISK`
echo "Before: $x"
x=$[ (($x) % 4) + 1 ]
echo "After: $x"
echo $x > DISK
It's horribly lacking in sanity checking. Such as verifying there is only
one line and one character in DISK. But if you run it several times, it
will count from 1 to 4 and start over.
-james
More information about the wplug
mailing list