I am currently running 2 scripts to gather data for a 3rd script and would like to combine the 2 scripts into one. Having issues with the final output format.
Note cannot post URL so replaced the http stuff with (name) in the examples
All scripts contain #!/bin/ksh OS = Red Hat Enterprise 5.x, and comments left out for simplicity
Objective: 1) find all sub-directories in a path that contain a specific file
a. Keep that path where the file was found
Script 1:
find /path -type d -exec sh -c '[ -d "$1"/.svn ] || exit 1' sh {} \; -print | cat > FileLocation.dat
Objective : 2) Using the FileLocation.dat list grep for a string replace the string and print both "OldString NewString" adding commands. print to new script file to be executed later.
Script 2:
for i in `cat /scripts/FileLocation.dat`
do
OldString= grep svnFoo.abc ${i}/.svn/entries | tail -1
NewString= grep svnFoo.abc ${i}/.svn/entries | tail -1 | sed '/svnFoo.abc/ s/svnFoo.abc/svnBar/g' | sed 's/\/svnFoo//g' | sed 's/\/UnwantedinPath//g'
echo "cd $i svn relocate $OldString $NewString"
done
Script 2 is piped to cat > relocate.dat
relocate.dat looks like this for each location
cd /path/to/file/location svn relocate
(name)svnFoo.abc/UnwantedinPath/repopath
(name)svnBar.abc/repopath
Objective : 3 What I need is for relocate.dat ( to be used as relocate.sh )
to be formatted as two lines: (both URLs on same line)
cd /path/to/file/location
svn relocate (name)svnFoo.abc/UnwantedinPath/repopath (name)svnBar.abc/repopath
thus creating the 3rd script that is the primary script to be executed to do a batch relocate ( will be executed on a Windows Server as a bat file )
Added this to sort out duplicates
cat /scripts/relocate.dat | sort -u | sed '$!N; /^\(.*\)\n\1$/!P; D' | cat > /scripts/relocate.sh
Nice to have is the reverse for backout just exchange Foo and Bar path