Created
January 26, 2015 15:05
-
-
Save martynjarvis/9f57a495fa86e0820d69 to your computer and use it in GitHub Desktop.
Automatically incrementing run number in bash script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# counter for current run number | |
if [ ! -e "${HOME}/.counter" ] | |
then | |
echo "creating counter file" | |
echo "1" > ~/.counter | |
fi | |
while read line | |
do | |
runNo=$line | |
done < ~/.counter | |
# Now do stuff with $runNo | |
echo $runNo | |
# update counter | |
let "runNo += 1" | |
echo "$runNo" > ~/.counter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment