I have the following requirement in the shell script
-
I have more than 200 shell script files. I need to find out how many shell scripts have "sqlplus /" in the shell file
-
I need to replace all the shell scripts in the single command
for example: connect scott/scott
replace as connect prod1/prod1
#take backup of entire folder
cp -fr original_folder /tmp/backup
# replace using sed commnad
sed -i 's/connect scott\/scott/connect prod1\/prod1/g' *.sh
The shell script contains directory and subdirectory. also I need to count how man shell script has the following lines
sqlplus /"
for i in *.sh
do
sed -i 's/connect scott\/scott/connect prod1\/prod1/g' $i
done
---------- Post updated at 09:55 AM ---------- Previous update was at 09:53 AM ----------
#for count the files which has "sqlplus /"
find . -type f | xargs grep -l "sqlplus \/" | wc -l
Thanks for your quick reply.
My scripts file contain in the following directory
for example
directory /a/b/c/d
the given find command will work for counting the files
to replace multiple files
find . -name "*.sh" -exec sed -i "s/connect scott\/scott/connect prod1\/prod1/g" '{}' \;
In the shell script I am connecting the database using below method
sqlplus -s prod/prod1@prod
Prod1 is the password in the shell script, How to hide the password in the script or calling the password from other location
Password should not be open to all users