07-27-2010
Quote:
Originally Posted by
Ikon
I guess its like you said its a case related ability/bug. I dont see why 1-9 would work and 1-10 wouldn't though.
Some more knowledge about RE [] might make you see why range 1-9 would work but 1-10 doesn't work as you expected.
If you want to match a double digit number you can not do it as you has been trying.
[1-9] matches any single number between 1 and 9, said digits included
[1-9][0-9] matches any two digits number as long as the first digit is between 1 and 9 and the second digit 0 through 9
Now [1-20] matches any single digit 1 through 2 or 0
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all,
is it possible to create a 'dynamic' case statement.
ie
select option in `ls`
do
case satement depending on results of the above `ls`
done
I hope I have explained this ok!
Thanks
Helen (1 Reply)
Discussion started by: Bab00shka
1 Replies
2. Shell Programming and Scripting
Hi,
I'm trying to write a shell script that has a menu and then dependant on the selection, will automate some samba file transfer.
The problem is when I run the code without the case statement it runs fine. but when I put the case statement in the only way I can get the code to run is to... (6 Replies)
Discussion started by: ianf
6 Replies
3. Shell Programming and Scripting
Hi All,
this small script is written to recognize user input character.. it is in small case .. upeer case or is a number... but when i input first capital letter say A.. it always gives small character.... what is the problem.
#!/bin/bash
echo "Enter the character"
read a
case $a in
)... (2 Replies)
Discussion started by: johnray31
2 Replies
4. UNIX for Dummies Questions & Answers
I want to write a program with the following variables:
a=7000
b=24000
c=613.8
The user can enter two words: Vivid or Blue for example. The challenge is that the user might not want to write the words the way they appear. The user can write V or v or vivid or Vivid or write Blue or blue, or B,... (1 Reply)
Discussion started by: Ernst
1 Replies
5. Shell Programming and Scripting
In a case statement like below :
case $rental in
"car") echo "For $rental Rs.20 per k/m";;
"van") echo "For $rental Rs.10 per k/m";;
"jeep") echo "For $rental Rs.5 per k/m";;
"bicycle") echo "For $rental 20 paisa per k/m";;
*) echo "Sorry, I can not gat a $rental for you";;... (4 Replies)
Discussion started by: sriram003
4 Replies
6. Shell Programming and Scripting
I'm in the process of writng a function that consists of a case statement is there a way of calling the function and passing a value to it?
ie
function1 () {
case
opt1 do .....
opt2 do.....
esac
}
function opt1
I'm aware the syntax is not correct, but you get the general idea. (1 Reply)
Discussion started by: squrcles
1 Replies
7. Shell Programming and Scripting
have written the below code to check whether the string received from user is a file name or dir using case statement, but its going into default case*).
#!/bin/sh
#Get a string from user and check whether its a existing filename or not
rm str2
rm str3
echo "enter a file \c"
read fil... (8 Replies)
Discussion started by: Mohan0509
8 Replies
8. Shell Programming and Scripting
Hi Gurus,
I have a very weird requirement and have no clue to resolve the issue. please help me get out this difficulty
below two tables, table1 contains the column name. D means this column used for the rule. for example: rule 0 is all columns have value, rule1 is col3 and col7 have no value.... (2 Replies)
Discussion started by: Torhong
2 Replies
9. Shell Programming and Scripting
Foe example we have three environments int,qa and prod.Each environment has some number of servers.
int=Server1,Server2,Server3
qa=Server4,Server5,Server6
prod=Server7,Server8,Server9
echo "Enter the Environment i.e int,qa,prod"
read env
case $env in
int)
## Need command where all the... (9 Replies)
Discussion started by: nareshreddy443
9 Replies
10. Shell Programming and Scripting
Linux System having all Perl, Python, PHP (and Ruby) installed
From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file
eg
eg
a Shell script run in a case statement call to run a php file, also Perl or/and Python file???
Like
#!/usr/bin/bash
....
....
case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies
FNMATCH(3) 1 FNMATCH(3)
fnmatch - Match filename against a pattern
SYNOPSIS
bool fnmatch (string $pattern, string $string, [int $flags])
DESCRIPTION
fnmatch(3) checks if the passed $string would match the given shell wildcard $pattern.
PARAMETERS
o $pattern
- The shell wildcard pattern.
o $string
- The tested string. This function is especially useful for filenames, but may also be used on regular strings. The average user
may be used to shell patterns or at least in their simplest form to '?' and '*' wildcards so using fnmatch(3) instead of
preg_match(3) for frontend search expression input may be way more convenient for non-programming users.
o $flags
- The value of $flags can be any combination of the following flags, joined with the binary OR (|) operator.
A list of possible flags for fnmatch(3)
+-------------+---------------------------------------------------+
| $Flag | |
| | |
| | Description |
| | |
+-------------+---------------------------------------------------+
| | |
|FNM_NOESCAPE | |
| | |
| | Disable backslash escaping. |
| | |
| | |
|FNM_PATHNAME | |
| | |
| | Slash in string only matches slash in the given |
| | pattern. |
| | |
| | |
| FNM_PERIOD | |
| | |
| | Leading period in string must be exactly matched |
| | by period in the given pattern. |
| | |
| | |
|FNM_CASEFOLD | |
| | |
| | Caseless match. Part of the GNU extension. |
| | |
+-------------+---------------------------------------------------+
RETURN VALUES
Returns TRUE if there is a match, FALSE otherwise.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.0 | |
| | |
| | This function is now available on Windows plat- |
| | forms. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
Checking a color name against a shell wildcard pattern
<?php
if (fnmatch("*gr[ae]y", $color)) {
echo "some form of gray ...";
}
?>
NOTES
Warning
For now, this function is not available on non-POSIX compliant systems except Windows.
SEE ALSO
glob(3), preg_match(3), sscanf(3), printf(3), sprintf(3).
PHP Documentation Group FNMATCH(3)