|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | 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
|
|||
|
|||
|
Clarification required on sed
Hi
Can some one tell what does this sed command do sed 's/[]*[]$//g I am more curious on the highlighted part , can some one explain what does that mean. Thanks Sri |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
The final $ is an anchor, means end of the line. That's easy. Now the outer brackets: Code:
[]*[] mean "match any one of these characters". E.g., if you have [abd], it will match any of the chars 'a', 'b', 'd'. So the whole thing will strip (substitute with empty string) any trailing ],[,or * on the line (only one character). 'g' is unnecessary, because of the $ anchor, you cannot substitute any further. And to make this syntactically correct, we need a closing single quote also. Here: Code:
$ echo 'sfj[dd]aa[][]*sd[667]qf[[]]*[]' | sed 's/[]*[]$//' sfj[dd]aa[][]*sd[667]qf[[]]*[ To strip all the trailing ],[, or *, you just an *, quantifier: Code:
$ echo 'sfj[dd]aa[][]*sd[667]qf[[]]*[]' | sed 's/[]*[]*$//' sfj[dd]aa[][]*sd[667]qf Last edited by mirni; 02-03-2012 at 03:41 AM.. Reason: added example |
| 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 |
| clarification Required in Write command | little_wonder | Shell Programming and Scripting | 3 | 02-01-2010 09:04 PM |
| Getting required fields from a test file in required fromat in unix | rdhanek | Shell Programming and Scripting | 7 | 07-22-2009 11:35 AM |
| Clarification | Shahul | Web Programming | 1 | 08-16-2008 04:05 AM |
| Script required to get a required info from file. Pls. help me. | ntgobinath | Shell Programming and Scripting | 2 | 05-31-2008 08:34 AM |
| Need clarification | ravi.sadani19 | Shell Programming and Scripting | 2 | 04-13-2007 01:55 AM |
|
|