Hi
How do i compare two strings in shell script. Below is an example but I am not getting the desired output, plz help
if
then
echo success
fi
I am not getting the desired output if I do this. plz help (24 Replies)
Hi All,
While I am trying to run below code I Am getting the exception like
./abs.sh: line 102: syntax error near unexpected token `then'
./abs.sh: line 102: ` then'
The Code Snippet is:
if then
cat $file1 | sed -e... (8 Replies)
i have a string in a file which gets repeated number of times like below:
rpttxt("abc")
.
.
rpttxt("REP_TITLE")
rpttxt("BOS_TITLE")
.
.
.
.
and so on
using awk or grep how can i comapre the string( as the second half keeps varying) and store it in a temporary variable? I am using the... (3 Replies)
hi All
i am facing prob in comparing two strings that have two word.
below is the code snippet.
checkValidates="file validates"
file3_name="file"
if
then
echo "file" $file3_name "is validated successfully"
fi
when i run this i get the error as -bash: [: too many arguments
... (1 Reply)
Hey guys how do I compare 2 strings from the text file,
and check for duplication?
For example, I add an item call Laptop, it will record to the textfile call file.
If it detects duplicate it will say the record record exist?
file.txt contains
Laptop:Sony:1000
Phone:Apple:30
A head... (4 Replies)
Hello I'm very new to Linux and shell scripting so I only know basic stuff. I'm making a script with the purpose of finding the longest string or word in a file. Here's what I got so far:
#!/bin/bash
longest=""
for i in $(strings -n $1); do
if ]
then
longest=$i
fi
done
echo $longest... (4 Replies)
Hi, So I got his code below. $year is a string of 2010,2011 etc.
I guess I want to convert $year to an integer so I can do my if statement to see if the year string is greater than 2010? Or how could I do this?
Right now I get a syntax error doing this.
if; then
do stuff
fi (2 Replies)
Discussion started by: vsekvsek
2 Replies
LEARN ABOUT PHP
collator_compare
COLLATOR_COMPARE(3) 1 COLLATOR_COMPARE(3)Collator::compare - Compare two Unicode strings
Object oriented style
SYNOPSIS
public int Collator::compare (string $str1, string $str2)
DESCRIPTION
Procedural style
int collator_compare (Collator $coll, string $str1, string $str2)
Compare two Unicode strings according to collation rules.
PARAMETERS
o $coll
-Collator object.
o $str1
- The first string to compare.
o $str2
- The second string to compare.
RETURN VALUES
Return comparison result:
o 1 if $str1 is
greater than $str2 ;
o 0 if $str1 is
equal to $str2;
o -1 if $str1 is
less than $str2 .
On error boolean FALSE is returned.
Warning
This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on
Booleans for more information. Use the === operator for testing the return value of this function.
EXAMPLES
Example #1
collator_compare(3)example
<?php
$s1 = 'Hello';
$s2 = 'hello';
$coll = collator_create( 'en_US' );
$res = collator_compare( $coll, $s1, $s2 );
if ($res === false) {
echo collator_get_error_message( $coll );
} else if( $res > 0 ) {
echo "s1 is greater than s2
";
} else if( $res < 0 ) {
echo "s1 is less than s2
";
} else {
echo "s1 is equal to s2
";
}
?>
The above example will output:
SEE ALSO collator_sort(3).
PHP Documentation Group COLLATOR_COMPARE(3)