![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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. |
|
||||
|
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
|
![]() |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|