Detecting if folder exists and renaming by pattern
Me again with another command-line script question :)
I made a helper script that looks like this
echo 'target.bak -> target.old_bak'
mv target.bak target.old_bak
echo 'target -> target.bak'
mv target target.bak
echo 'git clone:target -> target'
git clone ssh://Shark@mcs15:29418/our-trunk-target target
cd target
echo 'Managing hooks...'
scp -p -P 29418 Shark@mcs15:/hooks/commit-msg .git/hooks/
echo '... done. Enjoy the new clone while it lasts...'
This is pretty basic but it gets my point across - it keeps the last two clones and makes a new one, I need to retain my latest clone in the target folder because i symlinked my source folder in my eclipse project to point there :D
I would like to make an improvement to this script - instead of renaming target.bak -> target.old_bak and target -> target.bak I would like the following to happen:
if bakN exists then rename bakN -> bak(N+1)
rename recursivelly bak(N-1) -> bakN
rename target to target.bak
clone new repo into target
So in case I had gone through 6 clones and I'm cloning for the seventh time I'd like this to happen:
target.bak4 -> target.bak5
target.bak3 -> target.bak4
target.bak2 -> target.bak3
target.bak1 -> target.bak2
target.bak0 -> target.bak1
target -> target.bak0
Cloning into 'target'...
This community helped me immensely with my previous mass-diffing question so I hope you will be helpful enough to provide me with a decent way to do this one as well :)
Me again with another command-line script question :)
I made a helper script that looks like this
echo 'target.bak -> target.old_bak'
mv target.bak target.old_bak
echo 'target -> target.bak'
mv target target.bak
echo 'git clone:target -> target'
git clone ssh://Shark@mcs15:29418/our-trunk-target target
cd target
echo 'Managing hooks...'
scp -p -P 29418 Shark@mcs15:/hooks/commit-msg .git/hooks/
echo '... done. Enjoy the new clone while it lasts...'
This is pretty basic but it gets my point across - it keeps the last two clones and makes a new one, I need to retain my latest clone in the target folder because i symlinked my source folder in my eclipse project to point there :D
I would like to make an improvement to this script - instead of renaming target.bak -> target.old_bak and target -> target.bak I would like the following to happen:
if bakN exists then rename bakN -> bak(N+1)
rename recursivelly bak(N-1) -> bakN
rename target to target.bak
clone new repo into target
So in case I had gone through 6 clones and I'm cloning for the seventh time I'd like this to happen:
target.bak4 -> target.bak5
target.bak3 -> target.bak4
target.bak2 -> target.bak3
target.bak1 -> target.bak2
target.bak0 -> target.bak1
target -> target.bak0
Cloning into 'target'...
This community helped me immensely with my previous mass-diffing question so I hope you will be helpful enough to provide me with a decent way to do this one as well :)
No comments:
Post a Comment