check if one string comes before another


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting check if one string comes before another
# 8  
Old 11-26-2011
Quote:
Originally Posted by vanessafan99
does the exit mean that it exits the program? its part of a program so it should be running still
You need only one pattern match to set the value to true, after that you can exit.

Quote:
Originally Posted by vanessafan99
its not working
it doesnt detect it as true when the pattern exists
Check your input and patterns again.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cant check empty string

Hello So i have that script collection, in which i have a single script to create a configuration file. In there, i have multiple occourences of something like this: prj_title=$(tui-read "What is the TITLE? ($prj_name):") ] && prj_title="${prj_name/_/ }" They all work as expected, if... (5 Replies)
Discussion started by: sea
5 Replies

2. Shell Programming and Scripting

Check for rows with particular string

Hi. The data file is as below: 2000922111111100232091212098324.... 2123011230912832094820943684896.... 3435983453409583405938453049583.... . . . I need to get only the rows that match my criteria. For example: those at characters 5-10 should equal to "922111" (thus getting only the 1st... (7 Replies)
Discussion started by: daytripper1021
7 Replies

3. Shell Programming and Scripting

Check file for string existence before appending it with string

I want to append file with a string but before doing that i want to check if this string already exist in that file.I tried with grep on Solaris 10 but unsuccessful.Man pages from grep seems to suggest if the string is found command status will be 0 and if not 1.But i am not finding it.May be i... (2 Replies)
Discussion started by: sahil_shine
2 Replies

4. Shell Programming and Scripting

A nice way to check a string

Guys, I need some advice on how to check a string, which may or may not have a entry.. Never really worked out how to do this.. May be a good time to learn now. This is what i am trying to do Run a command, to return a string If the string is not empty , then run the if statement,... (4 Replies)
Discussion started by: Junes
4 Replies

5. Shell Programming and Scripting

check if a string is numeric

I checked all the previous threads related to this and tried this. My input is all numbers or decimals greater than zero everytime. I want to check the same in the korn shell script. Just validate the string to be numeric. This is what I am doing. var="12345" if ) -o "$var" !=... (14 Replies)
Discussion started by: megha2525
14 Replies

6. UNIX for Advanced & Expert Users

check if a variable contains a string

hi I have an if condition that states: if ; then exit how to translate this? $x is a path $y is a string that comes at the end of the path thx (11 Replies)
Discussion started by: melanie_pfefer
11 Replies

7. Shell Programming and Scripting

how to check string of character

how can i check whether variable contains only character from a-z or A-Z....if my variable contains any alpha numeric, numeric or any character with some special one i.e. *%&@! etcetera etcetera....then it should show me please enter only characters...... Let my variable var1="abc77}|" then... (9 Replies)
Discussion started by: manas_ranjan
9 Replies

8. Shell Programming and Scripting

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies

9. Shell Programming and Scripting

How to check a string in the variable

hi, I have a variable var1 as follows in the script. var1="one two three desformat=PDF xyz" I would like to check whether $var1 has a string "desformat=PDF" or not. Is there any command I can use (not need to creat a file)? Currently, I am using this: if ( grep "desformat=PDF"... (1 Reply)
Discussion started by: josephwong
1 Replies
Login or Register to Ask a Question
STRING(3)						     Library Functions Manual							 STRING(3)

NAME
strcat, strncat, strcmp, strncmp, strcpy, strncpy, strlen, index, rindex - string operations SYNOPSIS
char *strcat(s1, s2) char *s1, *s2; char *strncat(s1, s2, n) char *s1, *s2; strcmp(s1, s2) char *s1, *s2; strncmp(s1, s2, n) char *s1, *s2; char *strcpy(s1, s2) char *s1, *s2; char *strncpy(s1, s2, n) char *s1, *s2; strlen(s) char *s; char *index(s, c) char *s, c; char *rindex(s, c) char *s; DESCRIPTION
These functions operate on null-terminated strings. They do not check for overflow of any receiving string. Strcat appends a copy of string s2 to the end of string s1. Strncat copies at most n characters. Both return a pointer to the null-termi- nated result. Strcmp compares its arguments and returns an integer greater than, equal to, or less than 0, according as s1 is lexicographically greater than, equal to, or less than s2. Strncmp makes the same comparison but looks at at most n characters. Strcpy copies string s2 to s1, stopping after the null character has been moved. Strncpy copies exactly n characters, truncating or null- padding s2; the target may not be null-terminated if the length of s2 is n or more. Both return s1. Strlen returns the number of non-null characters in s. Index (rindex) returns a pointer to the first (last) occurrence of character c in string s, or zero if c does not occur in the string. BUGS
Strcmp uses native character comparison, which is signed on PDP11's, unsigned on other machines. STRING(3)