[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
# 22  
Old 08-19-2013
I downloaded and installed solaris.
Quote:
find / -name "*.sh" -exec grep -li "text_to_search" '{}' \;
And it works Smilie
This User Gave Thanks to smoofy For This Post:
# 23  
Old 09-04-2013
Quote:
Originally Posted by smoofy
I downloaded and installed solaris.
And it works Smilie
Works for me tooo.

Can you explain it please?Smilie
# 24  
Old 09-04-2013
It works with -iname as well, try:

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

as I said before, -iname option makes find to search for case insensitive pattern within the quotes and -exec just simply executes comand to every file found and inserts it's name istead of the curly brackets. grep option -l makes grep to print file name that actually contains the pattern within the grep's quotes and -i cause case insensivitiness.

Is that clear enough?
This User Gave Thanks to smoofy For This Post:
# 25  
Old 09-10-2013
Quote:
Originally Posted by smoofy
It works with -iname as well, try:

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

as I said before, -iname option makes find to search for case insensitive pattern within the quotes and -exec just simply executes comand to every file found and inserts it's name istead of the curly brackets. grep option -l makes grep to print file name that actually contains the pattern within the grep's quotes and -i cause case insensivitiness.

Is that clear enough?
Hi Smoofy,

Thanks

How can i remove these errors from output

Code:
find: cannot read dir /var/fm/fmd/ckpt: Permission denied
find: cannot read dir /var/preserve/skoppana: Permission denied
find: cannot read dir /var/mysql: Permission denied
find: cannot read dir /var/run/smc898: Permission denied
find: cannot read dir /var/sma_snmp: Permission denied

# 26  
Old 09-10-2013
Try:
Code:
find / -name "*.sh" -exec grep -li "text_to_search" '{}' \; 2>/dev/null

This User Gave Thanks to smoofy For This Post:
# 27  
Old 09-10-2013
Quote:
Originally Posted by smoofy
Try:
Code:
find / -name "*.sh" -exec grep -li "text_to_search" '{}' \; 2>/dev/null

It works Smilie
# 28  
Old 09-11-2013
Glad to be helpful Smilie
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