0

Hi everyone,

I am not really a scripter by nature but now have the need to create one that handles sequential numbering.

Basically I need the script to create a sequential number everytime its run. I dont expect anyone to tell me how to do it as i want to learn. I just need some pointers for where to start.

Thanks in advance

googlybear

1
Contributor
1
Reply
2
Views
10 Years
Discussion Span
Last Post by googlybear
0

Hi everyone,

I am not really a scripter by nature but now have the need to create one that handles sequential numbering.

Basically I need the script to create a sequential number everytime its run. I dont expect anyone to tell me how to do it as i want to learn. I just need some pointers for where to start.

Thanks in advance

googlybear

Well after having a coffee, i figured it out. So incase anyone else needs this i have added the little script below:

#!bin/bash
#
# Get number from file, increment by one
# then append file
#
CODE=XW-R-
COUNTER="`tail -1 /incrementregister`"
INCREMENT="`expr $COUNTER + 1`"
RETURNSNUMBER="$CODE`expr $COUNTER + 1`"
echo $RETURNSNUMBER >> /returnsregister
echo "NEW RETURNS NUMBER:"
tail -1 /returnsregister
echo $INCREMENT >> /incrementregister
echo "NEW INCREMENT NUMBER:"
tail -1 /incrementregister
echo "Both above numbers should match"


And if anyone wonders what i needed this for, it will be accessed by procmail when certain emails come in. Then those emails will be autoreplied with the new returns number in the subject line.

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.