[Solved] Finding a word in all shell scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Finding a word in all shell scripts
# 15  
Old 08-19-2013
I see. Solaris does not have GNU find so try:
Code:
find / -name ‘your-file.name'....

instead and finish with -exec blabla ';'
# 16  
Old 08-19-2013
Code:
find / -name "*.sh" -exec grep -Hi "word_to_search"  {} \;

# 17  
Old 08-19-2013
Quote:
Originally Posted by fpmurphy
Code:
find / -name "*.sh" -exec grep -Hi "word_to_search"  {} \;

Hi Murphy,
My OS is SunOS
When i executed your command i got a message

Code:
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
grep: illegal option -- H
Usage: grep -hblcnsviw pattern file . . .
find: stat() error /usr/share/gnome/javahelp/iiim-properties/pt_BR/JavaHelpSearch: Permission denied
find: stat() error /usr/share/gnome/javahelp/iiim-properties/pt_BR/figures: Permission denied
find: stat() error /usr/share/gnome/javahelp/iiim-properties/pt_BR/apply-to-all-lang.html: Permission denied
find: stat() error /usr/share/gnome/javahelp/iiim-properties/pt_BR/ar01s02s01.html: Permission denied
find: stat() error /usr/share/gnome/javahelp/iiim-properties/pt_BR/ar01s02s02.html: Permission denied

# 18  
Old 08-19-2013
your grep does not know option -H so use -l. Stat error is given because of the incorect user permissions.
This User Gave Thanks to smoofy For This Post:
# 19  
Old 08-19-2013
Quote:
Originally Posted by smoofy
your grep does not know option -H so use -l. Stat error is given because of the incorect user permissions.
Smoofy thanks .So tell me what command i can useSmilie
# 20  
Old 08-19-2013
Try:
find / -name `*.sh` -exec grep -li "word_to_search" '{}' ';'
# 21  
Old 08-19-2013
Quote:
Originally Posted by smoofy
Try:
find / -name `*.sh` -exec grep -li "word_to_search" '{}' ';'
I ran your command and got this

Code:
find / -name `*.sh` -exec grep -li "word_to_search" '{}' ';'

bash: ./altertable.CBS00017961.sh: Permission denied
find: bad option grep
find: [-H | -L] path-list predicate-list


Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] How to refer more than 9 command line inputs for a scripts in korn shell?

Hi all, I have a script which should take more than 9 command line inputs while running. Likescript.sh a s d f g h j j k l o p i u y t r e w Now in the script if I have to access one of the input which is at position after 9, in this case say 'p' then how can I do that? echo $12 will not work... (15 Replies)
Discussion started by: pat_pramod
15 Replies

2. Shell Programming and Scripting

[Solved] Search for a word and print the next word

Hi, I am trying to search for a word and print the next word. For example: My text is "<TRANSFORMATION TYPE ="Lookup Procedure">" I am searching for "TYPE" and trying to print ="Lookup Procedure" I have written a code like following: echo $line | nawk... (4 Replies)
Discussion started by: sampoorna
4 Replies

3. Shell Programming and Scripting

[Solved] Running scripts in parallel

i have script A and script B, both scripts have to run in parallel, my requirement is script A create table temp1, post creating it will run fr 4 hrs , script B has to start 0nly after creation of table temp1 ( which is done by script A) , again script B will run for 5 hrs if i run sequencially... (7 Replies)
Discussion started by: only4satish
7 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Finding the Files In the Same Name Directories

Hi, In the Unix Box, I have a situation, where there is folder name called "Projects" and in that i have 20 Folders S1,S2,S3...S20. In each of the Folders S1,S2,S3,...S20 , there is a same name folder named "MP". So Now, I want to get all the files in all the "MP" Folders and write all those... (6 Replies)
Discussion started by: Siva Sankar
6 Replies

5. Shell Programming and Scripting

[Solved] Finding the next line when a pattern matches

Hi I have a file like this Record 182: Rejected No Data found Record 196: Rejected File Not Found Record 202: Rejected Invalid argument Record 212: Rejected Bad data My requirement is to search for the value "Record" and if found, then return the next line of it. So,... (3 Replies)
Discussion started by: mr_manii
3 Replies

6. Shell Programming and Scripting

Finding a specific word

Hi, I am trying to develop a script which should find a word if a particular word exists. Below is the content of the file. insert_job: test_job ----> job name days_of_week: all start_times: "16:00" date_conditions: 1 insert_job: test_job2 ----> job name days_of_week: all... (16 Replies)
Discussion started by: rpatty
16 Replies

7. Shell Programming and Scripting

Solved: finding diff in files

i want to compare 2 files and generate below 3 files: 1. new lines 2. updated lines 3. deleted lines are there any one liners for each one of them. Note the method to find duplicates is based on field 1, values are separated by '|' example: test1 (older file) 1|XXX 2|YYY... (3 Replies)
Discussion started by: manishma71
3 Replies

8. Emergency UNIX and Linux Support

Getting last 50 lines after finding a word

Hi All, I have a requirement as below I need find for a string in a log file and once i found that string i need to send a mail.Thsi can be done thru grep and mailx cmnd. Here once i found the string i need to send last 50 lines(up) from where string found. Actually they require to find... (9 Replies)
Discussion started by: pssandeep
9 Replies

9. Shell Programming and Scripting

Finding a word in a file

Hi frndz, i have a flat file like, xxx yyy zzz sss aaa bbb yyy xxx rrr sss ttt yyy ddd zzzz cccc.. look, in this file i want to fetch the substring from one yyy to another one and need to print it then from next values between yyy's.. can you please give me some inputs on this.. ... (10 Replies)
Discussion started by: smr_rashmy
10 Replies

10. UNIX for Dummies Questions & Answers

finding out tables not used in scripts.

Hi all, Please see my requirement and post me asap. Spool all the tables names into a file . Take each table name and check if it is present in any of the scripts in a directory using grep -il command. The script has to loop through the tables list and take each table and find it's presence... (7 Replies)
Discussion started by: Vasundhara
7 Replies
Login or Register to Ask a Question