Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'You guys are just great!' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
You guys are just great!
Authored by: mael on Jul 30, '04 11:05:01AM
I love the shell, unfortunately I'll usually don't know about its features. Hints like these (the fact that webloc's save their data in resource forks and the fact that you can see this with cat /rsrc) make my day.

So I can now script a converter for synchronizing bookmarks between my mac, the pc and the solaris box. jipiiiee!

Instead of many different commands (grep, tr, sed) I'd go for using as little as possible. one part of osteslag's version could be reduced to


<dev_tools_path>/DeRez -e -only "url "  <inster_file_here> | sed -e 's/.*\/\* \(.*\) \*\//\1/' | sed -e :a -e '$!N; s/\n//; ta' -e 's/^.*{\(.*\)};/\1/'
Unfortunately I don't find clear "field boundaries" in the cat /rsrc-output, which I'd prefer so as not to be dependent on the Dev Tools (which are not on production machines...)

Any idea?

[ Reply to This | # ]

Works now without DeRez
Authored by: mael on Jul 30, '04 11:40:53AM
Found it.

cat <insert_filename>.webloc/rsrc | tr -d "\000" | sed 's/.*\(http:.*\).http:.*/\1/'

Gotta love shellscripts... Power in your hands...

[ Reply to This | # ]

Works now without DeRez
Authored by: sjk on Jul 30, '04 09:47:28PM
I've been using this:

strings site.webloc/rsrc | grep http | sed 's/^.//' | head -1



[ Reply to This | # ]
Works now without DeRez
Authored by: juanfc on Jul 31, '04 09:19:34AM

That eats the 'h' from the 'http://....' leaving 'ttp://..'

:(

---
---
juan



[ Reply to This | # ]
Works now without DeRez
Authored by: juanfc on Jul 31, '04 09:24:44AM
Why

| sed 's/^.//'
drop it out and it ought to work better:

strings $1.webloc/rsrc | grep http | head -1

---
---
juan

[ Reply to This | # ]

.webloc URL extraction
Authored by: sjk on Aug 01, '04 10:48:06PM

Did that to strip off the one random character prepended to "http://..." that 99% of my .webloc resource files have when I've run 'em thru strings and was too lazy to write the one-liner to handle the 1% exception that don't. I'll fix it later ...



[ Reply to This | # ]
.webloc URL extraction
Authored by: sjk on Aug 01, '04 11:37:55PM
First revision:

strings ${1}.webloc/rsrc | grep http | sed '/^.http/s//http/' | head -1

TODO:
Generalize for non-http/https URL schemes.
Optimize to eliminate grep and head.

[ Reply to This | # ]