![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| moving directories to new directories on multiple servers | mackdaddy07 | Shell Programming and Scripting | 0 | 04-06-2007 08:30 AM |
| append 3 users in /etc/passwd | melanie_pfefer | Shell Programming and Scripting | 3 | 03-23-2007 02:36 AM |
| SQLplus in Shell scripts | trupti_d | Shell Programming and Scripting | 12 | 03-16-2007 05:46 AM |
| Scripts for ID´s free in /etc/passwd | oscar_acm | Shell Programming and Scripting | 2 | 11-15-2005 08:50 PM |
| sqlplus and sh scripts (to_char command)) | josecollantes | UNIX for Advanced & Expert Users | 4 | 09-06-2001 06:59 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
editing sqlplus id@passwd in multiple scripts, users and directories
hi all,
i was given by my supervisor a task to search for scripts which contain oracle sqlplus i.e "myusername/mypasswd @myDB" in every /home/userfolder, which are, all the scripts made by different user. I've done some find command to search string for sqlplus, but it may up too long to respond. And it was searching, some directories denied the permission to read the files. May be it was the admin folder(right?i new to UNIX). therefore, i try to search some example in this forum but, unlucky to find one similarly. I need help to clear me up: 1) i log on as normal user only, so, it is possible to editing scripts like i mention above? what about that sort of "permission"?should asking for super user id or not? 2) how am i going to seek for oracle sqlplus scripts which have the "myusername/mypasswd @myDB" in every sh scripts,perl etc in every user directories. And if it found it, it is enable to modified? 3) is there any example/testing sed scripts which i seem maybe would help for the task? thanks in advance, regards, helmi |
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
find . -name '*.*' -print | xargs grep -il 'searchpattern' if enough permission is not available then use the following form find . -name '*.*' -print 2>/dev/null | xargs grep -il 'searchpattern' Quote:
root permission is not required as such, it is enough if you have the perms of the owner or write perm to the group atleast Quote:
|
|
|||
|
for "search pattern" you can use:
grep -i "sqlplus.*\@" This will find all occurrences of sqlplus, followed by any number of characters, followed by the @ sign. The backslash "\" escapes the @ sign so as not to be interpreted by the shell. |
|
|||
|
i think most unix operating systems support the following
find . -type f -exec grep -l sqlplus.*\@ {} \; find from the current directory down, all files - execute the command 'grep -l sqlplus.*\@' on each of the files grep -l sqlplus.*\@ displays each file name that contains sqlplus followed by any character up to the '@' sign Last edited by TinWalrus; 05-08-2007 at 06:28 PM. |
|
|||
|
Thanks for the replies.
Quote:
Code:
find . -name '*.*' -print | xargs grep -il 'searchpattern' | sed 's/oldsearchpattern/newsearchpattern/g' (i don't know if this is the correct term of using sed!) Code:
in /home/user/ a.sh b.sh c.sh is there any example shell script/sed scripts that could alter or modified all three scripts where i just input the new "user/passwd @DB" when i running the example script. sorry for much of request, Regards, Helmi |
|
|||
|
you could do something like the following...
Code:
#!/bin/ksh
for file in $(find . -type f -exec grep -l sqlplus.*\@ {} \;); do
echo ${file}
sed -e 's%sqlplus user/pword@sid%sqlplus newuser/newpword@newsid%g' < ${file} > ${file}.$$
mv ${file}.$$ ${file}
done
replace newuser, newpword,newsid with replacement run from parent directory, you should back up everything first Last edited by TinWalrus; 05-08-2007 at 07:50 PM. |
|
|||
|
thanks all!
i try to think that if the script to edit the sqlplus is running, it will also edit the all the variables that set in that editing scripts. Hence, if being executed for the second time, nothing will changed, right? using: Code:
find . -type f -exec grep -l sqlplus.*\@ {} \;
Code:
./sql ./editor.sh Regards, Helmi |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | |
| Display Modes | |
|
|