This should give you an idea of how to proceed:
--- cut here ---
#!/bin/sh
# This creates an array consisting of lower case letters, indexed
# from 0
A=(a b c d e f g h i j k l m n o p q r s t u v w x y z)
# Index through the array
for (( i=0 ; $((i<=25)) ; $((i++)) ))
do
echo "A[$i] = ${A[$i]} "
done
echo
--- cut here---
$ ./x
A[0] = a
A[1] = b
A[2] = c
...
A[23] = x
A[24] = y
A[25] = z
Hope this helps.
Kurt
-Original Message-
From: Ian [mailto:[EMAIL PROTECTED]]
Sent: Thu 1/31/2002 11:32 AM
To: SxS-users
Cc:
Subject:Incrementing Letter variables in bash
So far my searching hasn't turned up anything useful.
Is there a quick way to increment a letter variable in a bash script?
I am creating a script to automatically transfer files in a given
directory by creating a dated folder (mkdir $(date -I), copy files into
new folder and create a .log of the files using the output of 'ls'.
The issue here is that in order to stick to an existing convention, more
than one transfer in the same day has a '-a' or '-b' appended to the
directory and .log file names.
I've not been able to come up with a clever way to automatically
increment the letter to be appended, for example if '-a' has already
been taken for a given day. It's not the checking part that I have
trouble with, it's incrementing a _letter_.
Before I create some ugly monstrosity of a loop to do this, can anyone
offer any hints? Scripting has never been my strong suit...I can read
scripts quite well, but tend to "complexify" simple tasks due to lack of
experience.
--
Linux SxS [http://sxs.webhop.net]
___
Linux-users mailing list - http://linux.nf/mailman/listinfo/linux-users
Subscribe/Unsubscribe info, Archives,and Digests are located at the above URL.
<>