Below is the script as I have it now, I am still working on building it so it's not complete. Anyhow there is one area that is not working no matter how I try to get it to... and it's driving me crazy!
The setup/function...
I have a text file called... txtBuild.txt that contains the last build number of a project I am working on. Currently I have to manually tar the existing instance of the application, then manually copy over the new build so I can start using the new build. I am writing this script to use the last build number ( formatted this way YYYYMMDD-### ) for the tarball of the last build. Then the new build number is created ( that part works fabulously! ) and written into txtBuild.txt. But it isn't. And this is the problem I have been trying to sort out!
The script...
Code:
#!/bin/bash
clear
echo "Stand-by while installing updates."
# read in the build number file...
# this is the build number of the current application in use...
file="txtBuild.txt"
while read -r line; do
# read in value and extract the build number to be incremented by 1...
nline="${line%%\"*}" #strip everything from first " seen to the end
newline="${nline:10}" # gets everything to the right of the first 10 characters...
i=$(($newline+1)) # increment value by 1... this is the new build numer suffix example YYYYMMDD-032
# get year and month for the rest of the new build number...
YY= date +%Y%m%d"-0$i" # This works fine...
build="$YY"
echo $build # This works in that is will display the new build number to the terminal
# write that value back out to the file...
echo $build > "txtBuild.txt" # But this doesn't work as it just deletes the content and does not write the new value to the file... ggrrrrrr!
# create the tarball name with the value and date
tar -cvpf $line.tar.gz -T TarList.txt # This works in that the tarball is created with the old build number as the name... perfect!
done <$file
Any ideas why I can't write the new build number to the text file? It's really making no sense to me at all why it isn't working...