grep question - match a url


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers grep question - match a url
# 1  
Old 04-10-2008
grep question - match a url

I'm trying to find files which have urls such as "services/amf/fri/home.html" and "services/amj/fri/air.html" - so the pattern I want to match with grep, logically, is one that has

1. "services/"
2. stuff in between including slashes, numbers, underscores etc
3. ending in "html"

Can anyone point me in the right direction?

Thanks,

PJ
# 2  
Old 04-10-2008
try this
Code:
egrep 'services\/.*\.html$'

# 3  
Old 04-10-2008
Quote:
Originally Posted by wempy
try this
Code:
egrep 'services\/.*\.html$'

Didn't work as is, but gives me some ideas to play around with.
# 4  
Old 04-11-2008
This did it:

Code:
grep "services/.*html$" file.txt

The . is for any character and so the * means 0-many occurances of any character. There should be no \ infront of the . since that causes it to be viewed as a period rather than a wildcard.

Thanks for the pointer!

P
# 5  
Old 04-11-2008
Hi what is use of $ at end?
# 6  
Old 04-11-2008
$ in a regex means end of line
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading URL using Mechanize and dump all the contents of the URL to a file

Hello, Am very new to perl , please help me here !! I need help in reading a URL from command line using PERL:: Mechanize and needs all the contents from the URL to get into a file. below is the script which i have written so far , #!/usr/bin/perl use LWP::UserAgent; use... (2 Replies)
Discussion started by: scott_cog
2 Replies

2. Shell Programming and Scripting

How to use GREP to extract URL from file

Hi All , Here is what I want to do: Given a line: 98.70.217.222 - - "GET /liveupdate-aka.symantec.com/1340071490jtun_nav2k8enn09m25.m25?h=abcdefgh HTTP/1.1" 200 159229484 "-" "hBU1OhDsPXknMepDBJNScBj4BQcmUz5TwAAAAA" "-" 1. Get the URL component: ... (2 Replies)
Discussion started by: Naks_Sh10
2 Replies

3. Shell Programming and Scripting

Assign grep match to variable question

Hi, I'm trying to assign a grep result to a variable but instead of having all grep result's assigned to the variable, would it be possible to assign the first match, do something, then move onto the next match and assign it to that variable and so on until all matches have been completed I... (4 Replies)
Discussion started by: Jazmania
4 Replies

4. UNIX for Dummies Questions & Answers

Awk: print all URL addresses between iframe tags without repeating an already printed URL

Here is what I have so far: find . -name "*php*" -or -name "*htm*" | xargs grep -i iframe | awk -F'"' '/<iframe*/{gsub(/.\*iframe>/,"\"");print $2}' Here is an example content of a PHP or HTM(HTML) file: <iframe src="http://ADDRESS_1/?click=5BBB08\" width=1 height=1... (18 Replies)
Discussion started by: striker4o
18 Replies

5. Shell Programming and Scripting

Perl regular expression - To match a Dynamic URL

Hello All, I have a requirement to match a dynamic url and extract each of the directory and page and store it -Only PERL style Regular EXP as it will be used in informatica - REG_EXTRACT function Example Input URLs: 1)... (2 Replies)
Discussion started by: jambesh
2 Replies

6. Web Development

Regex to rewrite URL to another URL based on HTTP_HOST?

I am trying to find a way to test some code, but I need to rewrite a specific URL only from a specific HTTP_HOST The call goes out to http://SUB.DOMAIN.COM/showAssignment/7bde10b45efdd7a97629ef2fe01f7303/jsmodule/Nevow.Athena The ID in the middle is always random due to the cookie. I... (5 Replies)
Discussion started by: EXT3FSCK
5 Replies

7. Shell Programming and Scripting

Need help to grep for a title match and then make some queries after the match

Here is the sample of my file address.txt Address 1 1234 Drive way New Orleans, LA Zipcode :- 12345 Address 2 4567 Spring way Chicago, IL Zipcode :- 67890 I would like to grep for an Address title (Ex :- Address 2) , then get its zipcode and echo both in a single line. Ex :- ... (3 Replies)
Discussion started by: leo.maveriick
3 Replies

8. Shell Programming and Scripting

How to open an url and grep for a word

Hi All, I am new to shell scripting,Could any of you help me on this below :confused: -------------------- I need to write a shell script where i have open an url and grep for a particular word in the url and want to display it in a flatfile. Eg: Want to open yahoo.com and grep for yahoo... (1 Reply)
Discussion started by: sumithra
1 Replies

9. Shell Programming and Scripting

pattern match url in string / PERL

Am trying to remove urls from text strings in PERL. I have the following but it does not seem to work: $remarks =~ s/www\.\s+\.com//gi; In English, I want to look for www. then I want to delete the www. and everything after it until I hit a space (but not including the space). It's not... (2 Replies)
Discussion started by: mrealty
2 Replies

10. UNIX for Advanced & Expert Users

url calling and parameter passing to url in script

Hi all, I need to write a unix script in which need to call a url. Then need to pass parameters to that url. please help. Regards, gander_ss (1 Reply)
Discussion started by: gander_ss
1 Replies
Login or Register to Ask a Question