![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| md5 hash a string or char array in SCO | jcarter2333 | High Level Programming | 5 | 02-08-2007 04:09 PM |
| replacing char with string | phani_sree | High Level Programming | 1 | 11-20-2006 08:57 AM |
| string of 7 char length always... | thanuman | UNIX for Dummies Questions & Answers | 3 | 04-12-2005 12:51 PM |
| Compare Char to String | Phobos | High Level Programming | 3 | 04-09-2005 11:01 AM |
| Number of specific char in a string. | gio123bg | Shell Programming and Scripting | 7 | 12-19-2003 02:27 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
Pattern-matching for fun and profit!
Code:
# x="/unix/*" # y="/unix/" # z="/unix" # [[ $x == *@(/|\*) ]] && echo TRUE || echo FALSE TRUE # [[ $y == *@(/|\*) ]] && echo TRUE || echo FALSE TRUE # [[ $z == *@(/|\*) ]] && echo TRUE || echo FALSE FALSE |
|
|||||
|
ok. i never saw something like that
![]() after some time trying to understand that, some googling, and some more thinking, i think i got what it does thats a nice feature i never read about !! i am sure alot of people will scream at me cause is really hard to read, but it does the trick (i will have to make a 10 lines comment for one if condition )thanks for the reply |
|
||||
|
This should do it:
Code:
case "$line" in *\*) echo "It ends in asterisk";; */) echo "It ends in slash";; *) echo "It ends in neither slash nor asterisk";; esac |
|
||||
|
Yep - you can use regular expressions like "^" to anchor it to the start of a line, "^[a-z]" to anchor it to a line starting with a letter, or any other variation you choose.
(It's Korn and POSIX shell syntax, but I think it's good for Bash too. I'm not sure how much of it works with basic Bourne shell though.) Basically have a play; it's like a stuck vending machine - you just have to find the right place to give it a thump. |
![]() |
| Bookmarks |
| Tags |
| linux, regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|