LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-12-2012, 10:51 PM   #1
tacticsWiz
LQ Newbie
 
Registered: Sep 2004
Location: USA
Distribution: Slackware 9.0
Posts: 29

Rep: Reputation: 0
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.
 
Old 08-12-2012, 11:34 PM   #2
divyashree
Senior Member
 
Registered: Apr 2007
Location: Bangalore, India
Distribution: RHEL,SuSE,CentOS,Fedora,Ubuntu
Posts: 1,386

Rep: Reputation: 135Reputation: 135
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
 
Old 08-13-2012, 01:07 AM   #3
tacticsWiz
LQ Newbie
 
Registered: Sep 2004
Location: USA
Distribution: Slackware 9.0
Posts: 29

Original Poster
Rep: Reputation: 0
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?
 
Old 08-13-2012, 01:34 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
. - any character
{40} - 40 of the previous character
 
Old 08-13-2012, 01:51 AM   #5
tacticsWiz
LQ Newbie
 
Registered: Sep 2004
Location: USA
Distribution: Slackware 9.0
Posts: 29

Original Poster
Rep: Reputation: 0
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?
 
Old 08-13-2012, 05:21 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by tacticsWiz View Post
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?
 
1 members found this post helpful.
Old 08-13-2012, 05:29 AM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by divyashree View Post
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.....
 
Old 08-13-2012, 08:47 AM   #8
tacticsWiz
LQ Newbie
 
Registered: Sep 2004
Location: USA
Distribution: Slackware 9.0
Posts: 29

Original Poster
Rep: Reputation: 0
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.
 
Old 08-13-2012, 09:58 AM   #9
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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.
 
  


Reply

Tags
grep



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
Creating an alias in ksh that uses grep and includes 'grep -v grep' doug248 Linux - Newbie 2 08-05-2012 02:07 PM
[SOLVED] run ps|grep command by script/command line ... ERROR: Unsupported option (BSD syntax) masuch Programming 4 05-23-2012 04:13 AM
How to pass the result of a command to another command (like grep) desb01 Programming 4 06-25-2009 12:09 PM
Help me in Grep Command + cd command in single line JeiPrakash Linux - Newbie 3 05-27-2008 04:16 AM
grep command in c????? alnreddy Linux - Software 1 12-30-2004 01:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:44 AM.

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