|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem with sed wildcard "*"
Hi All, can you help me with "*" wildcard character in sed, i am a bit confused. I am going through a reference and found that below code Code:
sed -n '/a*c/' file will also return a line that contain the string Code:
output : close the window properly how is that possible when there is no "a" in this string?? how does this wildcard works. Any reference/suggestion would be appreciated. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
a* - zero or more occurrences of a
|
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
It's capturing the 'c'. If you change the 'c' to a 'z', then nothing will be returned since there is neither an 'a' or 'z' in the string. Code:
$ sed -n '/a*c/p' file close the window properly $ sed -n '/a*z/p' file $ |
|
#4
|
|||
|
|||
|
Hi Vgresh, My output doesn't contain any occurrence of "a"
---------- Post updated at 11:52 PM ---------- Previous update was at 11:46 PM ---------- Thanks in2nix4life, Quote:
|
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Quote:
If you want to get lines where an 'a' is followed by anything and a 'c': a.*c |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Thanks Vgresh for your quick help, but i think i am not able to explain my problem properly.
can you please also explain a bit about '*' in sed? I tried but i am really getting confused with this. |
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
Quote:
What exactly are you trying to do? |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to use "cut" or "awk" or "sed" to remove a string | timmywong | Shell Programming and Scripting | 8 | 02-12-2012 11:55 AM |
| cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' | harshakusam | Shell Programming and Scripting | 4 | 08-25-2009 11:21 AM |
| A question/problem about oracle "tns listener" and "enterprise manager" | talipk | UNIX for Advanced & Expert Users | 1 | 12-03-2008 06:55 AM |
| A question/problem about oracle "tns listener" and "enterprise manager" | talipk | UNIX and Linux Applications | 0 | 12-01-2008 02:08 PM |
| Preventing wildcard expansion in "read" | gaijin 06 | UNIX for Dummies Questions & Answers | 8 | 11-01-2005 08:31 PM |
|
|