LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Grep Command Experssion (http://www.linuxquestions.org/questions/linux-newbie-8/grep-command-experssion-4175421784/)

tacticsWiz 08-12-2012 10:51 PM

Grep Command Experssion
 
:: Get host
grep -Eao 'rtmp.{40}' plugin-container.dmp | sort -u

What is the . for? Also, what do you think the {40} accomplishes?

I don't need help with the | sort -u part. I know what it is for.

divyashree 08-12-2012 11:34 PM

You may be missing a coma(,) between 4 and 0.

If coma is there it will grep rtmp.4, rtmp.0 from plugin-container.dmp

tacticsWiz 08-13-2012 01:07 AM

Not missing comma
 
I've seen the same code line in different places around the web and the line is the same - no comma.

Here's where I got this line of code from: http://svnpenn.blogspot.com/2011/07/...osts-file.html

Anybody else know what the rtmp.{40} bit does?

grail 08-13-2012 01:34 AM

. - any character
{40} - 40 of the previous character

tacticsWiz 08-13-2012 01:51 AM

40 periods
 
That would mean that the server name path would contain 40 periods. This doesn't make any sense...

Do we have anymore experienced people?

pixellany 08-13-2012 05:21 AM

Quote:

Originally Posted by tacticsWiz (Post 4752885)
Do we have anymore experienced people?

Sure---but do you think that's going to change the answer?

You are using grep -E, which means that the regex is using the "extended" syntax. In that syntax, "{x}" means "x occurences of the previous regex". "." means "any character".

SO....."rtmp.{40}" means "rtmp, followed by any 40 characters (including spaces)"

Who said it meant 40 periods?

pixellany 08-13-2012 05:29 AM

Quote:

Originally Posted by divyashree (Post 4752834)
You may be missing a coma(,) between 4 and 0.

If coma is there it will grep rtmp.4, rtmp.0 from plugin-container.dmp

I don't think so.....

tacticsWiz 08-13-2012 08:47 AM

wild characters
 
For some reason I overlooked that the other poster said that "." means any character. I'm used to using * or ? as the only wild characters. This is the first time I see a period used as a wild character. I guess I'm a bit rusty...

So now I see that what he wants is "rtmp" plus "://" and then the rest of the host address.

grail 08-13-2012 09:58 AM

The difference is that wildcards used the way you mentioned are for globbing in the shell (on the command line), however the example you are using here is a regular expression and hence
quite a different beast. If you search for regular expression or regex you will find a slew of information.


All times are GMT -5. The time now is 03:16 AM.