Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 08-02-2010, 09:47 PM   #1
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
sed command line help

I'm trying to get this sed command to work correctly. I need to retrieve a specific "string" from: terms_id=string&location
below is what i'm working with so far.

Code:
sed -ne 's/^.*terms_id=\([^&]*\)&.*$/\1/'
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-02-2010, 10:06 PM   #2
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,372
whats wrong with it?

test.txt

Quote:
terms_id=shit&location
terms_id=sex&location
terms_id=scat&location
terms_id=porn&location
terms_id=bbw&location
terms_id=teen&location
Quote:
[chris@jumbo ~]$ sed 's/^.*terms_id=\([^&]*\)&.*$/\1/' test.txt
shit
sex
scat
porn
bbw
teen
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-02-2010, 10:24 PM   #3
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by fris View Post
whats wrong with it?

test.txt
hmm I noticed that you removed -ne, it works without that. also is there a way to make it append the outputs each time the command is run? it seems to be writing a new file each time I run the command. thanks

Code:
sed 's/^.*terms_id=\([^&]*\)&.*$/\1/' test.txt > getIDs.txt
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-02-2010, 10:30 PM   #4
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,372
test.txt >> getIDS.txt
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-02-2010, 10:30 PM   #5
CYF
Coupon Guru
 
CYF's Avatar
 
Industry Role:
Join Date: Mar 2009
Location: Minneapolis
Posts: 10,973
Quote:
Originally Posted by acctman View Post
hmm I noticed that you removed -ne, it works without that. also is there a way to make it append the outputs each time the command is run? it seems to be writing a new file each time I run the command. thanks

Code:
sed 's/^.*terms_id=\([^&]*\)&.*$/\1/' test.txt > getIDs.txt
sed 's/^.*terms_id=\([^&]*\)&.*$/\1/' test.txt >> getIDs.txt
__________________
Webmaster Coupons Coupons and discounts for hosting, domains, SSL Certs, and more!
AmeriNOC Coupons | Certified Hosting Coupons | Hosting Coupons | Domain Name Coupons

CYF is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-02-2010, 10:39 PM   #6
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
thanks Fris and CYF
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-02-2010, 11:54 PM   #7
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
back with another question. it keeps grabbing all the html coding around the string. I can see that its finding the string in the output but its also grabbing the html coding content as well.


Code:
#! /bin/sh

if [ $# -ne 2 ]; then
    echo "usage: $0 termfile baseurl" >&2
    exit 1
fi
termfile="$1"
baseurl="$2"

while read term; do
    wget -q -O- "$baseurl/server.php?all=$term" |
		sed 's/^.*terms_id=\([^&]*\)&.*$/\1/'
done < "$termfile"
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.