[Xsh-users] can not get sort to sort at all
Brought to you by:
pajas
From: Heiko B. <he...@bl...> - 2008-12-07 14:33:09
|
Hello, whatever i try, sort is a complete NOP for me ;-) and i thought my intention was pretty simple... all i wanted is to get a sorted list of the @bp:id 's of two files, like $OLD := open $old_file; $NEW := open $new_file; $ids := sort ($OLD//bp:device/@bp:id | $NEW//bp:device/@bp:id) ; print ($OLD//bp:device/@bp:id | $NEW//bp:device/@bp:id) ; print "ids: " $ids; 1 2 3 4 5 6 7 8 9 1 2 3 4 5 9 7 8 ids: 1 1 2 2 3 3 4 4 5 5 6 7 9 8 7 9 8 umh... then i tried all kinds of things with :k and :n in the script and interactively (see below), but never i got it to change anything at all. seems i have a fundamental misunderstandig here? TIA, heiko --------------------------------------- xsh - XML Editing Shell version 2.1.1 --------------------------------------- Copyright (c) 2002 Petr Pajas. This is free software, you may use it and distribute it under either the GNU GPL Version 2, or under the Perl Artistic License. Using terminal type: Term::ReadLine::Perl Hint: Type `help' or `help | less' to get more help. $scratch/>open sort.xml parsing sort.xml done. />ls //bp:device <bp:device bp:id="1" bp:version="7"> <bp:comment>updated first example device</bp:comment> </bp:device> <bp:device bp:id="2" bp:version="5"> <bp:comment>second example router</bp:comment> </bp:device> <bp:device bp:id="5" bp:version="5"> <bp:comment>7200 router</bp:comment> </bp:device> <bp:device bp:id="3" bp:version="4"> <bp:comment>third example router</bp:comment> </bp:device> Found 4 node(s). />$list := sort :n :k@bp:id //bp:device/@bp:id />print $list 1 2 5 3 />ls $list id='1' id='2' id='5' id='3' Found 4 node(s). />$list := sort :n :k@id //bp:device/@bp:id />print $list 1 2 5 3 />$list := sort :k@bp:id //bp:device/@bp:id />print $list 1 2 5 3 />$list := sort :k@id //bp:device/@bp:id />print $list 1 2 5 3 />$list := sort //bp:device/@bp:id />print $list 1 2 5 3 />$list := sort :n //bp:device/@bp:id />print $list 1 2 5 3 -- Heiko@Blume.AG Cisco Certified Network Professional Cisco Certified Design Professional Juniper Certified Internet Specialist SUN Certified System Administrator Office: +49.30/4426309 FAX: +49.30/48494354 Mobile: +49.178/6662342 www: http://www.blume.ag/IT/ PHY: Knaackstrasse 6, 10405 Berlin, DE |