04-16-2008
Then you'll need to take out the ^ after all. Make sure there are no accidental matches then, though.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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)
Discussion started by: ragha81
24 Replies
2. UNIX for Advanced & Expert Users
I have two strings
a=Mar22
b=may21
how can I compare them
Is this fine
if then;
.
...
else
....
fi
or
if then (2 Replies)
Discussion started by: yakyaj
2 Replies
3. Shell Programming and Scripting
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)
Discussion started by: Anji
8 Replies
4. Shell Programming and Scripting
hi
i have 2 strings. i want to compare the strings.
please help (2 Replies)
Discussion started by: satish@123
2 Replies
5. Shell Programming and Scripting
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)
Discussion started by: infyanurag
1 Replies
6. Shell Programming and Scripting
Hello All
Please I have got a file called DATE.tex which consist of
01-04-2008_12:00:00
01-04-2005_12:00:00
01-04-2003_12:00:00
01-04-2007_12:00:00
01-04-2002_12:00:00
01-04-2009_12:00:00
I want to use nawk to print out the dates >=01-04-2009_12:00:00
I tried this
cat plnt.new |... (6 Replies)
Discussion started by: ganiel24
6 Replies
7. Shell Programming and Scripting
Input:
The the
the the
Output:
not-same
same
What would be the sed command to do this? (7 Replies)
Discussion started by: cola
7 Replies
8. UNIX for Dummies Questions & Answers
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)
Discussion started by: SCB
4 Replies
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
Hi I tried the following string comparison script in Ksh88
#!/bin/ksh
str1='aC'
str2='ABC'
if
then
echo "Equal"
else
echo "Not Equal"
fi
Though str1 and str2 are not equal the script output says Equal .
Please correct me
Thanks (2 Replies)
Discussion started by: smile689
2 Replies
LEARN ABOUT DEBIAN
regexp::shellish
Shellish(3pm) User Contributed Perl Documentation Shellish(3pm)
NAME
Regexp::Shellish - Shell-like regular expressions
SYNOPSIS
use Regexp::Shellish qw( :all ) ;
$re = compile_shellish( 'a/c*d' ) ;
## This next one's like 'a*d' except that it'll
## match 'a/d'.
$re = compile_shellish( 'a**d' ) ;
## And here '**' won't match 'a/d', but behaves
## like 'a*d', except for the possibility of high
## cpu time consumption.
$re = compile_shellish( 'a**d', { star_star => 0 } ) ;
## The next two result in identical $re1 and $re2.
## The second is a noop so that Regexp references can
## be easily accomodated.
$re1 = compile_shellish( 'a{b,c}d' ) ;
$re2 = compile_shellish( qr/A(?:a(?:b|c)d)/ ) ;
@matches = shellish_glob( $re, @possibilities ) ;
DESCRIPTION
Provides shell-like regular expressions. The wildcards provided are "?", "*" and "**", where "**" is like "*" but matches "/". See "com-
pile_shellish" for details.
Case sensitivity and constructs like <**>, "(a*b)", and "{a,b,c}" can be disabled.
compile_shellish
Compiles a string containing a 'shellish' regular expression, returning a Regexp reference. Regexp references passed in are passed
through unmolested.
Here are the transformation rules from shellish expression terms to perl regular expression terms:
Shellish Perl RE
======== =======
* [^/]*
? .
** .* ## unless { star_star => 0 }
... .* ## unless { dot_dot_dot => 0 }
( ( ## unless { parens => 0 }
) ) ## unless { parens => 0 }
{a,b,c} (?:a|b|c) ## unless { braces => 0 }
a a ## These are de-escaped and
* * ## passed to quotemeta()
The wildcards treat newlines as normal characters.
Parens group in to $1..$n, since they are passed through unmolested (unless option parens => 0 is passed). This is useless when using
glob_shellish(), though.
The final parameter can be a hash reference containing options:
compile_shellish(
'**',
{
anchors => 0, ## Doesn't put ^ and $ around the
## resulting regexp
case_sensitive => 0, ## Make case insensitive
dot_dot_dot => 0, ## '...' is now just three '.' chars
star_star => 0, ## '**' is now two '*' wildcards
parens => 0, ## '(', ')' are now regular chars
braces => 0, ## '{', '}' are now regular chars
}
) ;
No option affects Regexps passed through.
shellish_glob
Pass a regular expression and a list of possible values, get back a list of matching values.
my @matches = shellish_glob( '*/*', @possibilities ) ;
my @matches = shellish_glob( '*/*', @possibilities, \%options ) ;
AUTHOR
Barrie Slaymaker <barries@slaysys.com>
perl v5.8.8 2002-01-24 Shellish(3pm)