LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 10-27-2005, 06:02 AM   #1
catzilla
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Rep: Reputation: 0
Question how to delete duplicates entries in xml file using sed/awk/sort ?


I want to use sed/awk/sort (or any other unix commands) to use in shell script to delete duplicate entries (except the original one) from xml file like this example


from

######################################

<?xml version="1.0" encoding="ISO-8859-1"?><markers>

<marker
defacer="TroJaN"
system="Win 2003"
/>

<marker
defacer="TroJaN"
system="Win 2003"
/>

<marker
defacer="TroJaN"
system="Win 2003"
/>

<marker
defacer="TroJaN"
system="Linux"
/>

<marker
defacer="Team-evil"
system="Linux"
/>

</markers>

###################################

to

###################################

<?xml version="1.0" encoding="ISO-8859-1"?><markers>

<marker
defacer="TroJaN"
system="Win 2003"
/>

<marker
defacer="TroJaN"
system="Linux"
/>

<marker
defacer="Team-evil"
system="Linux"
/>

</markers>

####################################

any approach please ? thanks in advance
 
Old 10-28-2005, 02:57 PM   #2
nilleso
Member
 
Registered: Nov 2004
Location: ON, CANADA
Distribution: ubuntu, RHAS, and other unmentionables
Posts: 372

Rep: Reputation: 31
Have you tried uniq?
Code:
NAME
     uniq - report or filter out repeated lines in a file

SYNOPSIS
     uniq [-c | -d |  -u]   [-f fields]  [-s char]  [  input_file
     [output_file]]

     uniq  [-c  |  -d  |  -u]   [-n]  [   +   m]   [   input_file
     [output_file]]

DESCRIPTION
     The uniq utility will read an input file comparing  adjacent
     lines,  and write one copy of each input line on the output.
     The second and succeeding copies of repeated adjacent  input
     lines will not be written.
cheers
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
....How to use awk to sort.... nisson Linux - General 12 11-02-2012 03:51 PM
[SOLVED] delete the end of each line in a file with sed angel115 Linux - Newbie 3 11-16-2005 04:41 PM
how could I delete duplicates entries in xml using php catzilla Programming 2 10-30-2005 07:08 PM
Help with a script to edit text file (awk? sed?) rickh Linux - Newbie 8 04-21-2005 08:24 PM
How to loop or sort in bash, awk or sed? j4r0d Programming 1 09-09-2004 03:22 AM


All times are GMT -5. The time now is 02:26 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration