Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

how to sort xml files in UNIX – xml, sorting, unix – how to sort in unix

Wir haben XML-Datei, (Datum:

You are watching: wie man in unix sortiert

wie man XML-Dateien in UNIX sortiert – XML, Sortierung, Unix

Wir haben XML-Datei, (Datum: TT / MM / JJ)

10110/12/13AAA10211/12/13BBB10109/12/13AAA10224/12/13BBB10101/12/13AAA10202/12/13BBB

Ausgabe sollte wie sein

10101/12/13AAA10109/12/13AAA10110/12/13AAA10202/12/13BBB10211/12/13BBB10224/12/13BBB

So sortieren Sie diese Datei nach , .

Antworten:

1 für die Antwort № 1

1 für die Antwort № 1

ich würde … benutzen sort zusammen mit sed. Wenn Sie zuerst auf Basis bestellen möchten pid und dann weiter date, fügen Sie nach jedem dieser Tags ein Leerzeichen hinzu und sortieren Sie dann entsprechend:

$ sed -e "s//& /" -e "s//& /" file | sort -nk2 -k3 | sed "s/ //g"
10101/12/13AAA10109/12/13AAA10110/12/13AAA10202/12/13BBB10211/12/13BBB10224/12/13BBB

Zuerst sed fügt ein Leerzeichen vor dem Datum ein und das letzte löscht es. Zwischen, sort -n -k2 -k3 sortiert numerisch (-n), erstens basierend auf Spalte 2 (-k2) und dann auf Spalte 3 (-k3).

0 für die Antwort № 2

Sortieren mit xidel

0 für die Antwort № 2

Dieser Befehl wird verwendet xidel um die angegebene Datei zu sortieren file.xml gemäß pid und date.

xidel --xquery "for $i in doc("file.xml")/* order by $i/pid, $i, $i/date return $i" --output-format xml

den Wurzelknoten betrachtend

Du brauchst immer ein Wurzelelement.

Link zum Thema

Fügen Sie also den Wurzelknoten zur Eingabe hinzu:

10110/12/13AAA10211/12/13BBB10109/12/13AAA10224/12/13BBB10101/12/13AAA10202/12/13BBB

Hinweis: Wie auch immer, xidel kann mit dieser multiplen Root-Struktur umgehen.

Für den Fall, dass alle Knoten, die die direkten Kinder des Wurzelknotens sind, haben und wie Kinder.

Und Ihre XML-Eingabedatei wird benannt file.xml.

Dieser Befehl gibt die obersten Knoten zurück, nachdem sie nach ihren untergeordneten Namen sortiert wurden und verwenden xidel.

xidel --xquery "
{for $i in doc("file.xml")/*/*
order by $i/pid, $i, $i/date
return $i}
" --output-format xml

Befehl in einer Zeile:

xidel --xquery "{for $i in doc("file.xml")/*/* order by $i/pid, $i, $i/date return $i}" --output-format xml

See more information related to the topic how to sort in unix

Linux sort command summary with examples

  • Author: FactorPad
  • Post date: 2016-10-17
  • Ratings: 4 ( 1311 Ratings )
  • Match search results: This Linux sort command tutorial shows you to sort lines within text files with examples and syntax. FactorPad Linux Essentials playlist covers your first 100 commands with examples.

    Find the code here:
    https://factorpad.com/tech/linux-essentials/sort-command.html

    Linux Essentials web page:
    https://factorpad.com/tech/linux-essentials/index.html

    https://factorpad.com

    Don’t lose this valuable resource, subscribe today. Happy Learning!

    Let’s connect!
    Email lists : http://visitor.r20.constantcontact.com/d.jsp?llr=ewszhmtab&p=oi&m=1120323553988&sit=jxabpaqjb&f=963f605b-ed0a-40a6-be03-00c983ecee37
    Facebook: http://facebook.com/factorpad
    Twitter: http://twitter.com/factorpad
    Pinterest: http://pinterest.com/factorpad
    YouTube: http://youtube.com/c/factorpad
    LinkedIn: http://linkedin.com/company/factorpad

how to sort xml file in UNIX

  • Author: stackoverflow.com
  • Ratings: 3 ( 2732 Ratings )
  • Match search results:

How do I sort a filename in Unix?

  • Author: www.compuhoy.com
  • Ratings: 3 ( 5839 Ratings )
  • Match search results: Si está buscando How do I sort a filename in Unix? haga clic aquí. En Compuhoy.com encontrarás todas las respuestas sobre sistemas operativos.

SORT command in Linux/Unix with examples

  • Author: www.geeksforgeeks.org
  • Ratings: 4 ( 8150 Ratings )
  • Match search results: A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

Sort Command Examples in Unix / Linux Tutorials

  • Author: www.folkstalk.com
  • Ratings: 4 ( 9590 Ratings )
  • Match search results: A data warehouse blog contains examples,interview questions and tutorials on Sql,Oracle Plsql,Unix Commands,Linux Commands,Informatica and Netezza.

sort – Unix, Linux Command

  • Author: www.tutorialspoint.com
  • Ratings: 5 ( 7998 Ratings )
  • Match search results: sort – Unix, Linux Command,
    Write sorted concatenation of all FILE(s) to standard output.

Use the sort command in Unix

  • Author: kb.iu.edu
  • Ratings: 4 ( 5860 Ratings )
  • Match search results: The sort command sorts the contents of a file, in numeric
    or alphabetic order, and prints the results to standard output
    (usually the terminal screen). The …

See more articles in this category: Computer tips

The post how to sort xml files in Unix – xml, sorting, unix – how to sort in unix appeared first on mlmdevelopers.com.



This post first appeared on Network Marketing, please read the originial post: here

Share the post

how to sort xml files in UNIX – xml, sorting, unix – how to sort in unix

×

Subscribe to Network Marketing

Get updates delivered right to your inbox!

Thank you for your subscription

×