LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-19-2008, 08:47 PM   #1
topheraholic
Member
 
Registered: Aug 2008
Location: shanghai
Distribution: ubuntu
Posts: 128

Rep: Reputation: 15
what does this mean in shell programming? thanks


stringZ=abcABC123ABCabc
echo `expr match "$stringZ" '\(.[b-c]*[A-Z]..[0-9]\)'` # abcABC1

you can see there is a "." and "*",what do they mean? why there is a . and * ?
thanks!
 
Old 12-19-2008, 09:00 PM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Homework?
You need to review your course notes about how regular expressions work.
 
Old 12-19-2008, 09:26 PM   #3
topheraholic
Member
 
Registered: Aug 2008
Location: shanghai
Distribution: ubuntu
Posts: 128

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Simon Bridge View Post
Homework?
You need to review your course notes about how regular expressions work.
no,it is not homework, i am new to shell, this is just the thing i do not understand.
thanks
 
Old 12-19-2008, 09:55 PM   #4
topheraholic
Member
 
Registered: Aug 2008
Location: shanghai
Distribution: ubuntu
Posts: 128

Original Poster
Rep: Reputation: 15
[QUOTE=Simon Bridge;3381762]Homework?
You need to review your course notes about how regular expressions work.[/QUOTE



i have seen this, but i still donot get it!
why there is two "."~

could you tell me more? thanks.
 
Old 12-19-2008, 10:49 PM   #5
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Not homework eh? It's a standard exercize in string manipulation.
See:
http://tldp.org/LDP/abs/html/string-manipulation.html

play with the expression - what happens if you change the stringZ? What happens if you use one dot instead of two? A star?
 
Old 12-19-2008, 10:52 PM   #6
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,716
Blog Entries: 3

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
what is the Burne shell http://www.injunea.demon.co.uk/pages/page203.htm the bigging to end
 
Old 12-19-2008, 11:02 PM   #7
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
@Drakeo: who is your post addressed to? ... surely you mean "Bourne Shell"? We are using the Bourne-Again Shell, or BASH. I'm confused: would you please explain the relevance of the history lesson?
 
Old 12-20-2008, 12:18 AM   #8
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,716
Blog Entries: 3

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
oh well your right I will stick to hardware. but it is all c to me hello world.
 
Old 12-20-2008, 06:28 AM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Perhaps this was Drakeo's way of trying to help OP........

For topheraholic:
I suggest going to http://tldp.org and getting the Bash Guide for Beginners.

In regular expressions (regexes):

"." = any character
"*" = any number of the previous regex

The specific meaning of characters can change with context, so you have to look at the syntax for each specific command.
 
Old 01-02-2009, 03:23 AM   #10
dhanyaelizabeth
LQ Newbie
 
Registered: Jan 2009
Posts: 27

Rep: Reputation: 15
Red face

Quote:
Originally Posted by topheraholic View Post
stringZ=abcABC123ABCabc
echo `expr match "$stringZ" '\(.[b-c]*[A-Z]..[0-9]\)'` # abcABC1

you can see there is a "." and "*",what do they mean? why there is a . and * ?
thanks!


Google anyone?

Linux Archive

Last edited by dhanyaelizabeth; 01-10-2009 at 03:08 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell programming qerf Linux - Newbie 5 11-06-2005 05:28 PM
shell programming shadowsurfer Linux - Newbie 3 09-09-2004 09:40 PM
SHELL programming whepin Linux - General 3 01-09-2002 02:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration