UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old January 22nd, 2004, 11:25 AM
bigfeller bigfeller is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 16 bigfeller User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 59 sec
Reputation Power: 0
Using sed on grep results...

I am trying to get some information from a load of different files (using grep) and then cut some of the information from it with sed. Unfortunately I know smeg all about sed and was wondering if you could help....

Basically the script looks like ...

Quote:

#!/usr/local/bin/bash

line2="http://www.myurl.com"
dom_folder="domain/"
line3="http://some.other.com"
DB="test"


grepline="domain/some.other.com/index.php?category=new:<img src=http://some.other.com/p.gif width=1 height=17><a href=http://www.myurl.com/ class=linkCat target=_blank>Blah blah blah blah...</a><br>"

grep -iRs "<a href=${line2}" $dom_folder${line3#*/\/}/* | sed -e 's/^\(.*\)$/ UPDATE results set page='\1/' where url='${line3}'' | psql $DB




The grepline is the results of the grep (obviously!) and what I need is the "index.php?category=new" bit...so I guess its a case of stripping up to the some.other.com and deleting everything after the ":". I need to put that page into a db, usually I use echo but amn't too sure if that'll work here.

At the moment when I run it all I get is...

Quote:

[bash]#./blah.bash
sed: here url=http://some.other.com: No such file or directory
[bash]#




Any help gratefully appreciated!!

Reply With Quote
  #2  
Old January 23rd, 2004, 05:41 AM
bigfeller bigfeller is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 16 bigfeller User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 59 sec
Reputation Power: 0
This did the trick....if anyone is interested!

dom_no_slash="domain"
page=`grep -iRs "<a href=${line2}" $dom_folder${line3#*/\/}/* | sed -e 's/'"$dom_no_slash"'\/'"${line3#*/\/}\/"'//g;s/:.*//g'`
echo "UPDATE results set page='${page}' where url='${line3}'" | psql $DATABASE

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Using sed on grep results...


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway