The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Calling a perl script from a perl script new2ss Shell Programming and Scripting 6 05-24-2009 05:03 PM
Include PERL script with in the unix shell script ganapati UNIX for Dummies Questions & Answers 1 04-29-2008 12:18 PM
here document to automate perl script that call script hogger84 Shell Programming and Scripting 3 10-22-2007 10:15 AM
Modify Perl script to work with txt - Permissions script joangopan Shell Programming and Scripting 1 09-12-2007 11:38 PM
Perl: Run perl script in the current process vino Shell Programming and Scripting 10 12-09-2005 10:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-02-2006
Terrible
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Desperately Need Help On This Perl script

ok, i dont know any perl. actually, very very little. not much at all.

now, the task i have is that i have to go into a directory that is packed with hundreds of files that contains lots of strings of which i have to filter through. so when i get into this directory, i type:

grep -r akamai * in the directory.


the above grep command spits out series of output similar to the below:

/excite/homepagepoll/ans_jan24_02.oft: <IMG SRC="http://a88.g.akamai.net/f/88/606/1d/image.lovesluudf.com/people/images/global/poll/popuptop.gif" WIDTH="468" HEIGHT="62" BORDER="0">


the path to the left of the colon of the above output represents the absolute path to the file in which the string i wanted is found.

now, my task is, i have to write a Perl script that will filter through the result of the "grep -r akamai *" and then produce a line that only contains the filename and the akamai string.

meaning, the resulting output should be something similar to:

/excite/homepagepoll/ans_jan24_02.oft: http://a88.g.akamai.net/f/88/606/1d/...l/popuptop.gif

basically, something that greps out the filename and the just the link(s) that is contained in that file which matches the "akamai"

sorry for the long read. but i just needed to clarify. someone please help. all i need is just something to get started with.
  #2 (permalink)  
Old 10-02-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
try this
Code:
grep -r akamai * | sed '/SRC=/s/\([^:]*\).*SRC="\([^"]*\)".*$/\1: \2/'
  #3 (permalink)  
Old 10-03-2006
Terrible
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Quote:
Originally Posted by anbu23
try this
Code:
grep -r akamai * | sed '/SRC=/s/\([^:]*\).*SRC="\([^"]*\)".*$/\1: \2/'

i'll give this a shot in a bit and let u know the results. i hope to god this works
  #4 (permalink)  
Old 10-03-2006
Terrible
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
nope it didn't work. is this anything else that can be done?
  #5 (permalink)  
Old 10-03-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Try this.
Code:
grep -r akamai * | sed -n -e "s+^\([^:]*:\).*\(http[^\"].*\)\".*+\1 \2+p"
Not tested tho.
  #6 (permalink)  
Old 10-03-2006
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,422
Alternative in Python:

Code:
s = '/excite/homepagepoll/ans_jan24_02.oft: <IMG SRC="http://a88.g.akamai.net/f/88/606/1d/image.lovesluudf.com/people/images/global/poll/popuptop.gif" WIDTH="468" HEIGHT="62" BORDER="0">'
splitted = s.split(":",1)
homepage,  = splitted[0]
urlpage = splitted[1].split()[1].replace('SRC="',"").replace('"',"")
final = homepage + ":" + urlpage
print final
  #7 (permalink)  
Old 10-03-2006
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,190
Any use to you?
Code:
grep -q akamai * | nawk -F'[<"]' '{print $1$3}'
Sponsored Links
Closed Thread

Bookmarks

Tags
perl, perl shift, shift, shift perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0