I had a situation where , I need to replace a word with 'replace' in 181 xsd files. where I used following simple command.
search string : types.xsd
replace string : common/types.xsd
command inside the directory conain files :
perl -pi -e 's/types.xsd/common\/types.xsd/g' *.xsd
Thursday, October 7, 2010
Wednesday, October 6, 2010
create 100 files in one command
Had a situation to create multiple xsd's in one location , i used following simple command .
"for (( i = 0 ; i < 100 ; i++ )) do touch $i.xsd; done;"
"for (( i = 0 ; i < 100 ; i++ )) do touch $i.xsd; done;"
Sunday, October 3, 2010
Kill all tomcat instances running by one command
kill -9 `ps ax | grep tomcat | grep -v grep | awk '{print $1}'`
You can improve this command to kill any process you want . just replace the 'tomcat'
with processor you want to kill .
You can improve this command to kill any process you want . just replace the 'tomcat'
with processor you want to kill .
Friday, October 1, 2010
changed files between two svn branch revisions
#!/bin/bash
#auther sanjeewaf
if [ ! $1 ] || [ ! $2 ] || [ ! $3 ] ; then
echo "Please enter a revision from, revision to, and SVN repository"
exit
fi
# set up nice names for the incoming parameters to make the script more readable
revision_from=$1
revision_to=$2
repository=$3
# the grep is needed so we only get added/modified files and not the deleted ones or anything else
# if it's a modified directory it's " M" so won't show with this command (good)
# if it's an added directory it's still "A" so will show with this command (not so good)
for line in `svn diff --summarize -r$revision_from:$revision_to $repository`
do
echo $line
done
# to summarize any deleted files or directories at the end of the script uncomment the following line
#svn diff --summarize -r$revision_from:$revision_to $repository | grep "^[D]"
#eg : 20 25 svn://localhost/myrepository
#auther sanjeewaf
if [ ! $1 ] || [ ! $2 ] || [ ! $3 ] ; then
echo "Please enter a revision from, revision to, and SVN repository"
exit
fi
# set up nice names for the incoming parameters to make the script more readable
revision_from=$1
revision_to=$2
repository=$3
# the grep is needed so we only get added/modified files and not the deleted ones or anything else
# if it's a modified directory it's " M" so won't show with this command (good)
# if it's an added directory it's still "A" so will show with this command (not so good)
for line in `svn diff --summarize -r$revision_from:$revision_to $repository`
do
echo $line
done
# to summarize any deleted files or directories at the end of the script uncomment the following line
#svn diff --summarize -r$revision_from:$revision_to $repository | grep "^[D]"
#eg : 20 25 svn://localhost/myrepository
shell script to run test files inside a package , status will be displayed
#!/bin/bash
#SRC_PATH=/home/user/workspaceNew
#cd $SRC_PATH/CPIIDA
echo "Test in Domain package ---------------------------------------------------------------"
for filename in `ls src/test/java/net/national/cp/domain/`
do
REG_EXP=".*(Test.java)"
#REG_EXP=".*(.txt)"
if [[ $filename =~ $REG_EXP ]]; then
#echo "fileName :"$filename
DD=0
DD=`mvn test -Dtest=$filename | grep -c "BUILD FAILURE"`
#echo $DD
if [ $DD != 0 ]
then
echo "************Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail***************"
echo "Test Fail In: $filename"
exit
else
echo "Test pass In : $filename "
fi
fi
done
echo "Test in Domain package are Successfully--------------------------------------------------------------"
echo "Test in Dao package ----------------------------------------------------------------"
for filename in `ls src/test/java/net/national/cp/dao/`
do
REG_EXP=".*(Test.java)"
#REG_EXP=".*(.txt)"
if [[ $filename =~ $REG_EXP ]]; then
#echo "fileName :"$filename
DD=0
DD=`mvn test -Dtest=$filename | grep -c "BUILD FAILURE"`
#echo $DD
if [ $DD != 0 ]
then
echo "************Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail***************"
echo "Test Fail In: $filename"
exit
else
echo "Test pass In : $filename "
fi
fi
done
echo "Test in Dao package are Successfully--------------------------------------------------------------"
#SRC_PATH=/home/user/workspaceNew
#cd $SRC_PATH/CPIIDA
echo "Test in Domain package ---------------------------------------------------------------"
for filename in `ls src/test/java/net/national/cp/domain/`
do
REG_EXP=".*(Test.java)"
#REG_EXP=".*(.txt)"
if [[ $filename =~ $REG_EXP ]]; then
#echo "fileName :"$filename
DD=0
DD=`mvn test -Dtest=$filename | grep -c "BUILD FAILURE"`
#echo $DD
if [ $DD != 0 ]
then
echo "************Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail***************"
echo "Test Fail In: $filename"
exit
else
echo "Test pass In : $filename "
fi
fi
done
echo "Test in Domain package are Successfully--------------------------------------------------------------"
echo "Test in Dao package ----------------------------------------------------------------"
for filename in `ls src/test/java/net/national/cp/dao/`
do
REG_EXP=".*(Test.java)"
#REG_EXP=".*(.txt)"
if [[ $filename =~ $REG_EXP ]]; then
#echo "fileName :"$filename
DD=0
DD=`mvn test -Dtest=$filename | grep -c "BUILD FAILURE"`
#echo $DD
if [ $DD != 0 ]
then
echo "************Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail Fail***************"
echo "Test Fail In: $filename"
exit
else
echo "Test pass In : $filename "
fi
fi
done
echo "Test in Dao package are Successfully--------------------------------------------------------------"
listfile in directory and rename file names
#rename the files in directory where file name contains '&' then sub string till that
#and make the file name
#!/bin/bash
##AUTHOR sanjeewaF
#SRC_PATH=/home/sanjeewaf/1/my
SRC_PATH=/home/sanjeewaf/1/my/feed
cd $SRC_PATH
echo "files in $SRC_PATH---------------------------------------------------------------"
for filename in `ls $SRC_PATH`
do
indexi=0
indexi=`expr index "$filename" "&"`
if [ $indexi -gt 0 ] ; then
echo "$filename will be rename as ${filename:0:$indexi-1}"
mv $filename ${filename:0:$indexi-1}
else
echo "$filename file is ignored"
fi
done
#and make the file name
#!/bin/bash
##AUTHOR sanjeewaF
#SRC_PATH=/home/sanjeewaf/1/my
SRC_PATH=/home/sanjeewaf/1/my/feed
cd $SRC_PATH
echo "files in $SRC_PATH---------------------------------------------------------------"
for filename in `ls $SRC_PATH`
do
indexi=0
indexi=`expr index "$filename" "&"`
if [ $indexi -gt 0 ] ; then
echo "$filename will be rename as ${filename:0:$indexi-1}"
mv $filename ${filename:0:$indexi-1}
else
echo "$filename file is ignored"
fi
done
Subscribe to:
Posts (Atom)