The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
how to get data from xml files tags(from data tags) pvr_satya Shell Programming and Scripting 9 08-16-2008 09:19 AM
Why are the xml tags not visible? photon Shell Programming and Scripting 1 04-06-2007 08:00 AM
Grep xml tags handak9 Shell Programming and Scripting 9 07-22-2005 02:51 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #1 (permalink)  
Old 02-08-2009
jeunium jeunium is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 8
process ma.gnolia_bookmarks for Diigo so that multiwords tags are preserved

Hi everyone.

I was lucky enough to backup all my bookmarks last xmas before the
recent complete meltdown of ma.gnolia.com

Unfortunately, when submitting the file to my new diigo account, all
multiword tags are converted to multiple single word tags which is not very
helpful for anyone searching through my tags.

Now I'm wondering how I can process the html file that contains
the bookmarks I managed to salvage (6500) using a combination
of akw and sed I suppose so I can adapt
the inner metadata as to preserve the tags integrity during the import into diigo.

Here is a sample of what the file contains:
Code:
<dt><A HREF="http://max.jsrhost.com/ajaxify/demo.php"
ADD_DATE="1230944239" LAST_MODIFIED="1230944239" 
TAGS="jquery, ajax, web devel tools">Ajaxify - jQuery plugin</A></dt>
<dd>Ajaxify is a jquery plugin that manage your ajax request</dd>
Using the previous code example, in TAGS="(.*?)"
  1. I need to replace the strings of 2 caracters: comma space
    with a single comma.
    Code:
    TAGS="jquery, ajax, web devel tools"
    becomes
    Code:
    TAGS="jquery,ajax,web devel tools"
  2. Then, in the same field, replace the remaning spaces with the underscore caracter.
    Code:
    TAGS="jquery,ajax,web devel tools"
    becomes
    Code:
    TAGS="jquery,ajax,web_devel_tools"
How would I do this using my linux shell?
I'd the like to share my findings with my fellow ma.gnoliers

Many thanks in advance

Jeunium
___________________________________
Amanita Muscaria
Is a man eater that must scare ya
  #2 (permalink)  
Old 02-08-2009
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,420
Try sed:
Code:
sed 's/, /,/g' file > newfile
  #3 (permalink)  
Old 02-08-2009
jeunium jeunium is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 8
Thanks for your answer danmero but wouldn't this do the replacement in all the file?

I want the replacements to occur only within the TAGS tag of each hyperlinks of my input file.

Thanks again for your time danmero

Jeunium
___________________________________
Amanita Muscaria
Is a man eater that must scare ya
  #4 (permalink)  
Old 02-08-2009
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,420
Sorry , I overseen the second requirement , try awk:
Code:
awk '{FS=OFS="\"";gsub(", ",","$2);gsub(" ","_",$2)}1' file > newfile
  #5 (permalink)  
Old 02-08-2009
jeunium jeunium is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 8
You are very generous denmero

I greatly appreciate your time and efforts on this but,

Where, in your command does it

limit the "search and replace" to only the TAGS=",,,,," part?

Code:
<dt><A HREF="http://max.jsrhost.com/ajaxify/demo.php"
ADD_DATE="1230944239" LAST_MODIFIED="1230944239" 
TAGS="jquery, ajax, web devel tools">Ajaxify - jQuery plugin</A></dt>
<dd>Ajaxify is a jquery plugin that manage your ajax request</dd>
Jeunium
___________________________________
Amanita Muscaria
Is a man eater that must scare ya
  #6 (permalink)  
Old 02-08-2009
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,420

Code:
awk  '{FS=OFS="\""}/TAGS/{gsub(", ",",",$2);gsub(" ","_",$2)}1' file > newfile

Last edited by danmero; 02-09-2009 at 10:01 AM.. Reason: Fix code
  #7 (permalink)  
Old 02-09-2009
jeunium jeunium is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 8
I think we're on to something here but it doesn't quite work yet.

Quote:
<A HREF="http://cssjuice.com/13-online-generators-for-web-20-design/" ADD_DATE="1186424504" LAST_MODIFIED="1186424477"
TAGS="web devel tools, online generators">CSS Juice - Design, Tutorial, Showcase and more » 13 Online Generators for Web 2.0 Design</A>
becomes

Code:
<A HREF="http://cssjuice.com/13-online-generators-for-web-20-design/" 
ADD_DATE="1186424504" LAST_MODIFIED="1186424477" 
TAGS="web devel tools,http://cssjuice.com/13-online-generators-for-web-20-design/online generators">
CSS Juice - Design,http://cssjuice.com/13-online-generators-for-web-20-design/Tutorial,
http://cssjuice.com/13-online-generators-for-web-20-design/Showcase and more » 13 Online Generators for Web 2.0 Design</A>
Let's remember that both substitutions must occur within the same
Quote:
TAGS="web devel tools, online generators"
which in this case should become
Quote:
TAGS="web_devel_tools,online_generators"
The substitions must occur ONLY within the TAGS="...." AND NOT on the whole line !!!

Thanks again danmero for your time.

Jeunium
___________________________________
Amanita Muscaria
Is a man eater that must scare ya

Last edited by jeunium; 02-09-2009 at 12:46 AM..
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0