Checking for the presence of a string within another string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking for the presence of a string within another string
# 1  
Old 03-20-2008
Checking for the presence of a string within another string

How to check if a string in contained in another string ?

Like

Whether the String "brown" is contained in
"A quick brown fox jumps over a lazy the dog"
# 2  
Old 03-20-2008
maybe something like this:

Code:
echo $string1 | grep $string2

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Checking not empty string

I have a string s Are the following equivalent? if ( ! s.empty() ) { } if ( s ) { } (1 Reply)
Discussion started by: kristinu
1 Replies

2. Shell Programming and Scripting

How to append string checking other same string?

Hi , I have a file likeA-0044150|ABC/Frito/ A-0044150|GFHU A-0150075|Bud Racing A-0187811|Bud Light A-0187811|RW&B signmaking I Want the o/p likeA-0044150|ABC/Frito/,GFHU A-0150075|Bud Racing A-0187811|Bud Light,RW&B signmaking (2 Replies)
Discussion started by: jagdishrout
2 Replies

3. Shell Programming and Scripting

checking co-presence of Var. - Shell or Perl

Hey fellas, I've posted this problem a few days back and I received just one post which was in PHP that I have no idea about! (Thanks to DGPickett) It would be so nice if you can help me with this in Shell or Perl. Here is the story: I have a big table with variables and observations. I... (9 Replies)
Discussion started by: @man
9 Replies

4. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

5. Shell Programming and Scripting

Checking for presence of any files

Is there code in Cshell scripting to check for the presence of any files in the current directory (and only the current directory)? I tried: if (-r *) then ... but Cshell doesn't like that. Thanks, Paul Hudgens (0 Replies)
Discussion started by: phudgens
0 Replies

6. Shell Programming and Scripting

Checking for presence of any files

I have tried the following script to check for the presence of any files in a folder: if (-r *) then goto ZipMiscFiles else echo "" echo " No Miscellaneous files found. Exiting program." echo "" exit endif The -r works fine with the wildcard in combo with other... (4 Replies)
Discussion started by: phudgens
4 Replies

7. Shell Programming and Scripting

string checking

lets think str is a variable...how can i check it is pure alphabetic or not for numeric checking i have used echo $str|grep -v ] but the command echo $str|grep -v ] is not working (1 Reply)
Discussion started by: arghya_owen
1 Replies

8. Shell Programming and Scripting

string checking

please help me providing the code of checking a string pure numeric or not and pure alphanumeric or not (6 Replies)
Discussion started by: arghya_owen
6 Replies

9. UNIX for Dummies Questions & Answers

Ksh Checking if string has 2 characters and does not contain digits?

How could I check if a string variable contains at least (or only) 2 characters, and check and make sure that the string does not contain any numeric digits?...I need to know how to do this as simple as possible. and I am using the Ksh shell. Thanks. (1 Reply)
Discussion started by: developncode
1 Replies

10. Shell Programming and Scripting

Checking if string contains integer

G'day guys, first post so be gentle. I need help with some code to work out if a variable (string) contains any integers. The valid variable (string) must contain only letters. Also need to be able to work out if a variable contains only integers. Any help greatly appreciated. (7 Replies)
Discussion started by: haz
7 Replies
Login or Register to Ask a Question