[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
# 1  
Old 08-19-2013
[Solved] Finding a word in all shell scripts

Hi i have to find the shell script that contain the word

PROC__TO_UPDATE

SEARCH SHOULD BE INSENSITIVE AND SCRIPT CAN BE DEPLOYED IN ANY PATH.

I am on Solaris.
# 2  
Old 08-19-2013
Hello,

Could you please be more specific in your requirement. Also please don't use capital letters while posting.


Thanks,
R. Singh
# 3  
Old 08-19-2013
What about:
Code:
find / -exec grep -l "word_to_search" '{}' ';'

# 4  
Old 08-19-2013
Quote:
Originally Posted by RavinderSingh13
Hello,

Could you please be more specific in your requirement. Also please don't use capital letters while posting.


Thanks,
R. Singh
Hi Ravinder,
Ok.Smilie

I am looking to find the word say "abcd" (they may be in small or capital letters)
in the .sh file.i want to display the name of the file along with the absolute path.

Something like

Code:
grep -i "abcd"  *.sh

---------- Post updated at 06:39 PM ---------- Previous update was at 06:36 PM ----------

Quote:
Originally Posted by smoofy
What about:
Code:
find / -exec grep -l "word_to_search" '{}' ';'

Is your search case insensitive?
I guess not
# 5  
Old 08-19-2013
Depends. If you wish the word you are looking for to be case insensitive add -i switch to grep command. Find is case insensitive as this very command will find every single file no matter what name it has got.
# 6  
Old 08-19-2013
Quote:
Originally Posted by smoofy
Depends. If you wish the word you are looking for to be case insensitive add -i switch to grep command. Find is case insensitive as this very command will find every single file no matter what name it has got.
like this

Code:
find / -exec grep -l -i "word_to_search" '{}' ';'

You mean to say -i is redundant here since find command is insensitive?
But find will be insensitive for FILE NAMES not its content right?




Plu i only want to search in .sh files

Last edited by rafa_fed2; 08-19-2013 at 10:25 AM..
# 7  
Old 08-19-2013
Exactly. Find does not consider content of the files at all. It just merely finds a file accordingly to condition. In this case we have no condition given so every file would do and for every one of them it runs that grep. -i switch is telling it not to care about case sensivitivity and -l just prints every file name that contains given string. Is that what you were looking for?
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