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 05-20-2011, 06:30 AM   #1
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,426
anyone good with sed?

im trying to grab all the links out of a chrome bookmark export file.

i want in the format of <a href="link">name</a>

Code:
 cat bookmarks_5_20_11.html | sed 's/^.*HREF="//' | sed 's/".*$//'
works just for the links, anyone have an idea how i can get the full link with title?
__________________
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 05-20-2011, 07:02 AM   #2
Juicy D. Links
So Fucking Banned
 
Industry Role:
Join Date: Apr 2001
Location: N.Y. -Long Island --
Posts: 122,992
Quote:
Originally Posted by fris View Post
im trying to grab all the links out of a chrome bookmark export file.

i want in the format of <a href="link">name</a>

Code:
 cat bookmarks_5_20_11.html | sed 's/^.*HREF="//' | sed 's/".*$//'
works just for the links, anyone have an idea how i can get the full link with title?
I have no clue
Juicy D. Links is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-20-2011, 07:11 AM   #3
Klen
 
Klen's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Little Vienna
Posts: 32,235
find /location/ -name "*.html" | xargs grep '<a href="link">name</a>'
Klen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-20-2011, 09:02 AM   #4
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,426
Quote:
Originally Posted by KlenTelaris View Post
find /location/ -name "*.html" | xargs grep '<a href="link">name</a>'
im looking to grab all the links from the export .html
__________________
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 05-20-2011, 11:07 AM   #5
Klen
 
Klen's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Little Vienna
Posts: 32,235
Quote:
Originally Posted by fris View Post
im looking to grab all the links from the export .html
Replace * with export
Klen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-20-2011, 11:47 AM   #6
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,426
Quote:
Originally Posted by KlenTelaris View Post
Replace * with export
that will only grep for the 1 link though.
__________________
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 05-20-2011, 11:54 AM   #7
Klen
 
Klen's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Little Vienna
Posts: 32,235
Google for command xargs and you should find proper example,saw tons of examples regarding what you looking for.
Klen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-20-2011, 02:35 PM   #8
V_RocKs
Damn Right I Kiss Ass!
 
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,428
Your problem is one of regex... coming up with a solution now...
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-20-2011, 02:36 PM   #9
marlboroack
So Fucking Banned
 
Industry Role:
Join Date: Jul 2010
Location: ☣
Posts: 9,327
Fuck if i know, help me help you.
marlboroack is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-20-2011, 02:37 PM   #10
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
you could probably get exactly what you want in one line by using 'cut'

cut -f(whereverhereitis) -d\" (or whatever the encapsulating format is) file
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-20-2011, 02:39 PM   #11
96ukssob
So Fucking Banananananas
 
96ukssob's Avatar
 
Industry Role:
Join Date: Mar 2003
Location: If I was in your ass you'd know it
Posts: 12,991
__________________
Email: Clicky on Me
96ukssob is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-20-2011, 03:08 PM   #12
V_RocKs
Damn Right I Kiss Ass!
 
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,428
Code:
cat bookmarks_5_20_11.html |grep 'DT><A' | sed 's/\s*//'|sed 's/<DT>//' | sed 's/\s*ADD_DATE="[^"]*"//'| sed 's/\s*ICON="[^"]*"//'
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-24-2011, 06:34 PM   #13
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,426
Quote:
Originally Posted by V_RocKs View Post
Code:
cat bookmarks_5_20_11.html |grep 'DT><A' | sed 's/\s*//'|sed 's/<DT>//' | sed 's/\s*ADD_DATE="[^"]*"//'| sed 's/\s*ICON="[^"]*"//'
thanks, nice one liner ;)

anyway to trim the space at the end of the " >

so its just <a href="link">test</a> instead of <a href="link" >test</a>
__________________
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 05-24-2011, 10:45 PM   #14
Socks
Confirmed User
 
Industry Role:
Join Date: May 2002
Location: Toronto
Posts: 8,475
Quote:
Originally Posted by fris View Post
thanks, nice one liner ;)

anyway to trim the space at the end of the " >

so its just <a href="link">test</a> instead of <a href="link" >test</a>
If your cursor is to the right of the space, you use backspace. If it's to the left, you have to use the delete key.
Socks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-25-2011, 08:03 AM   #15
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,426
Quote:
Originally Posted by Socks View Post
If your cursor is to the right of the space, you use backspace. If it's to the left, you have to use the delete key.
thanks fatfoo ;)

ps got it working

Code:
#!/usr/local/bin/bash

# chrome bookmark cleanup
# converts bookmark export to just links with titles

# our chrome bookmark export file

cat bookmarks.html | \

# grep the links

grep 'DT><A' | \

# remove the <DT> html tag

sed 's/<DT>//' | \

# remove the DATE variable from the link

sed 's/ ADD_DATE=\".*\"//g' | \

# remove the ICON variable from the link

sed 's/ ICON=\".*\"//g' | \

# remove leading whitespace

sed 's/^[ \t]*//' | \

# convert the html link tags to lowercase

tr '<A HREF' '<a href'
__________________
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 06-07-2011, 03:41 PM   #16
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,426
Quote:
Originally Posted by V_RocKs View Post
Code:
cat bookmarks_5_20_11.html |grep 'DT><A' | sed 's/\s*//'|sed 's/<DT>//' | sed 's/\s*ADD_DATE="[^"]*"//'| sed 's/\s*ICON="[^"]*"//'
found a shorter way.

Code:
cat bookmarks.html | sed '/<DT><A\|<DT><H3/!d;s/<DT>//;/Bookmarks bar/d;s/ ADD_DATE=\".*\"//g;s/^[ \t]*//;s/<A HREF/<a href/'
__________________
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
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.