![]() |
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 |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 03:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| how could i make a program mixed with many "|", "<" and ">" | strugglingman | High Level Programming | 2 | 04-29-2006 09:11 AM |
| No utpmx entry: you must exec "login" from lowest level "shell" | peterpan | UNIX for Dummies Questions & Answers | 0 | 01-18-2006 04:15 AM |
| what difference between "terminal" and "console" | chenhao_no1 | High Level Programming | 1 | 09-09-2002 10:46 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi frnds,
Can anybody please tell me what is the difference between "?" and "*" Regular expression. I have file called test.txt as follows a aa aba pqr xyz Both Code:
egrep "a?" test.txt Code:
egrep "a*" test.txt |
|
||||
|
That's what i am asking. I know "a?" means 0 or 1 occurrence of preceding pattern. I was thinking it as exactly 0 or 1 occurrence. but it's not like that. I am not getting the difference between "*" and "?" . If there is any can you give me some example of it.
|
|
||||
|
@gaurang:
Remember that you are doing a grep. That means the command will list down lines from the file that match the input pattern. In this case egrep works on your patterns a? and a* in the following way. egrep a? --> List down lines from test.txt if it contains an a followed by any character. Which means a, aa, abcdef, a897 all will match, and hence you get all these in the output. egrep a* --> List down lines from test.txt if it contains an a followed by 0 or more nr of characters. Again a, aa, abcdef, a897 all will match. Hope you get the point. Moreover, to see the difference between ? and *, create files with names : a, aa, a897, abcd and then do Code:
ls a? Code:
ls a* |
![]() |
| Bookmarks |
| Tags |
| regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|