{"id":17818,"date":"2025-01-17T20:50:19","date_gmt":"2025-01-17T19:50:19","guid":{"rendered":"https:\/\/linux-bibel.at\/?p=17818"},"modified":"2025-01-17T20:50:21","modified_gmt":"2025-01-17T19:50:21","slug":"dateien-am-terminal-unter-linux-wie-gewuenscht-sortieren-ls","status":"publish","type":"post","link":"https:\/\/linux-bibel.at\/index.php\/2025\/01\/17\/dateien-am-terminal-unter-linux-wie-gewuenscht-sortieren-ls\/","title":{"rendered":"Dateien am Terminal unter Linux wie gew\u00fcnscht sortieren &#8211; ls"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Jeder, der unter Linux hin und wieder mal am Terminal arbeitet, kennt den Befehl <code>ls<\/code> &#8211; er listet die Dateien und Verzeichnisse auf. In diesem Beitrag sehen wir uns an, wie wir die Ausgabe ganz einfach filtern lassen, ohne auf weitere Hilfsmittel zuzugreifen.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Beginnen wir mit der einfachsten Variante, also ganz einfach:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls.jpg\" rel=\"lightbox-0\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"158\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-1024x158.jpg\" alt=\"\" class=\"wp-image-17819\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-1024x158.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-1536x237.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-2048x316.jpg 2048w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-150x23.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-300x46.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-768x118.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Uns werden alle Dateien und Verzeichnisse im aktuellen Verzeichnis, in dem man sich am Terminal gerade befindet, angezeigt &#8211; Verzeichnisse sind meist blau und Dateien wei\u00df, dies kann aber je nach verwendeter Shell oder Farbschema auch abweichen. Geben wir den Pfad an, k\u00f6nnen wir auch ein beliebiges Verzeichnis auflisten:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls Dokumente\/<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-1.jpg\" rel=\"lightbox-1\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"441\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-1-1024x441.jpg\" alt=\"\" class=\"wp-image-17820\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-1-1024x441.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-1-1536x661.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-1-2048x882.jpg 2048w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-1-150x65.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-1-300x129.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-1-768x331.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Bisher haben wir uns nur sichtbare Dateien und Verzeichnisse angesehen, mit der Option <code>-a<\/code> k\u00f6nnen wir uns auch versteckte anzeigen lassen, also solche, die mit einem Punkt beginnen:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -a<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-2.jpg\" rel=\"lightbox-2\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"278\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-2-1024x278.jpg\" alt=\"\" class=\"wp-image-17821\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-2-1024x278.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-2-1536x417.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-2-2048x556.jpg 2048w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-2-150x41.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-2-300x81.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-2-768x208.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Durch die Option <code>-l<\/code> lassen wir uns die Berechtigungen an Verzeichnissen und Dateien anzeigen und noch so einige weitere Informationen:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -l<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-3.jpg\" rel=\"lightbox-3\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"632\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-3-1024x632.jpg\" alt=\"\" class=\"wp-image-17822\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-3-1024x632.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-3-1536x948.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-3-2048x1265.jpg 2048w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-3-150x93.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-3-300x185.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-3-768x474.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So sehen wir ganz links (<em>erstes Zeichen &#8211; <strong>d<\/strong> ist ein Verzeichnis, <strong>&#8211;<\/strong> es handelt sich um eine Datei<\/em>) die Rechte an der Datei oder dem Verzeichnis, es folgt der Besitzer und die Gruppe, die Gr\u00f6\u00dfe in Byte und das Datum der Erstellung, sowie zuletzt die Bezeichnung der Datei oder des Verzeichnisses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Wir k\u00f6nnen die Optionen nat\u00fcrlich auch kombinieren &#8211; die Gr\u00f6\u00dfe in Byte war irgendwann einmal interessant, dies ist aber schon l\u00e4ngere Zeit her &#8211; versuchen wir es mit der Option <code>-h<\/code> zus\u00e4tzlich:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -lh<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-4.jpg\" rel=\"lightbox-4\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"629\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-4-1024x629.jpg\" alt=\"\" class=\"wp-image-17823\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-4-1024x629.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-4-1536x943.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-4-2048x1258.jpg 2048w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-4-150x92.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-4-300x184.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-4-768x472.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Schon wird die Gr\u00f6\u00dfe in der n\u00e4chsten passenden Gr\u00f6\u00dfenordnung angezeigt.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Wir k\u00f6nnen uns die Dateien und Verzeichnisse auch nach der Uhrzeit der letzten \u00c4nderung anzeigen lassen:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">ls -lt<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-5.jpg\" rel=\"lightbox-5\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"630\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-5-1024x630.jpg\" alt=\"\" class=\"wp-image-17824\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-5-1024x630.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-5-1536x945.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-5-2048x1260.jpg 2048w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-5-150x92.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-5-300x185.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-5-768x472.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Oder wir k\u00f6nnen diese Ausgabe umkehren, also die \u00e4ltesten zuerst:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -ltr<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-6.jpg\" rel=\"lightbox-6\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"632\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-6-1024x632.jpg\" alt=\"\" class=\"wp-image-17825\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-6-1024x632.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-6-1536x948.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-6-2048x1264.jpg 2048w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-6-150x93.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-6-300x185.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-6-768x474.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Und uns gleichzeitig eine annehmbare Gr\u00f6\u00dfe genehmigen:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -lhtr<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-7.jpg\" rel=\"lightbox-7\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"630\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-7-1024x630.jpg\" alt=\"\" class=\"wp-image-17826\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-7-1024x630.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-7-1536x945.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-7-2048x1260.jpg 2048w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-7-150x92.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-7-300x185.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-7-768x473.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Dies k\u00f6nnen wir jetzt so weiterf\u00fchren, oder Sie sehen sich einfach die Manpage an:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>man ls<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Haben wir mit den M\u00f6glichkeiten, die uns die Manpage bietet nicht genug, k\u00f6nnte uns der zus\u00e4tzliche Befehl <code>sort<\/code> helfen. Beginnen wir noch einmal mit der Option <code>-lh<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -lh<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-8.jpg\" rel=\"lightbox-8\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"627\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-8-1024x627.jpg\" alt=\"\" class=\"wp-image-17827\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-8-1024x627.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-8-1536x940.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-8-2048x1254.jpg 2048w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-8-150x92.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-8-300x184.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-8-768x470.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Jetzt noch einmal dasselbe, diesmal \u00fcbergeben wir die Ausgabe von <code>ls<\/code> jedoch \u00fcber die Pipe <code>|<\/code> an <code>sort<\/code>. Die Option -h zeigt der Software, sie soll nach Zahlen sortieren, die Option <code>-k5<\/code> zeigt der Software, sie soll die Zahlen in der f\u00fcnften Spalte der Tabelle zum Sortieren nutzen:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-10.jpg\" rel=\"lightbox-9\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"628\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-10-1024x628.jpg\" alt=\"\" class=\"wp-image-17828\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-10-1024x628.jpg 1024w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-10-1536x942.jpg 1536w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-10-2048x1256.jpg 2048w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-10-150x92.jpg 150w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-10-300x184.jpg 300w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/01\/ls-10-768x471.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Dies war nur ein kleiner Teil der M\u00f6glichkeiten, die <code>ls<\/code> und <code>sort<\/code> k\u00f6nnen. Alles zu beschreiben, w\u00fcrde jedoch ganz einfach zu lange dauern &#8211; aber, auch bei <code>sort<\/code> hilft die Manpage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>man sort<\/code><\/pre>\n<div class=\"pld-like-dislike-wrap pld-custom\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"Gef\u00e4llt mir\" data-post-id=\"17818\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                            <img src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/12\/Daumen-Hoch.png\" alt=\"Gef\u00e4llt mir\" \/>\r\n            <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">2    <\/span>\r\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-dislike-trigger pld-like-dislike-trigger  \" title=\"Gef\u00e4llt mir nicht\" data-post-id=\"17818\" data-trigger-type=\"dislike\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                            <img src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/12\/Daumen-Runter.png\" alt=\"Gef\u00e4llt mir nicht\" \/>\r\n            <\/a>\r\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\"><\/span>\r\n<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Jeder, der unter Linux hin und wieder mal am Terminal arbeitet, kennt den Befehl ls &#8211; er listet die Dateien und Verzeichnisse auf. In diesem Beitrag sehen wir uns an, wie wir die Ausgabe ganz einfach filtern lassen, ohne auf weitere Hilfsmittel zuzugreifen. Beginnen wir mit der einfachsten Variante, also ganz einfach: Uns werden alle [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":17826,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[12,7,6],"class_list":["post-17818","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-terminal","tag-kommandozeile","tag-shell","tag-terminal"],"_links":{"self":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts\/17818","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/comments?post=17818"}],"version-history":[{"count":1,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts\/17818\/revisions"}],"predecessor-version":[{"id":17829,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts\/17818\/revisions\/17829"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/media\/17826"}],"wp:attachment":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/media?parent=17818"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/categories?post=17818"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/tags?post=17818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}