{"id":20800,"date":"2025-10-17T22:59:27","date_gmt":"2025-10-17T20:59:27","guid":{"rendered":"https:\/\/linux-bibel.at\/?p=20800"},"modified":"2025-10-17T22:59:29","modified_gmt":"2025-10-17T20:59:29","slug":"bat-textdateien-mit-rust-unter-linux-am-terminal-anzeigen","status":"publish","type":"post","link":"https:\/\/linux-bibel.at\/index.php\/2025\/10\/17\/bat-textdateien-mit-rust-unter-linux-am-terminal-anzeigen\/","title":{"rendered":"bat &#8211; Textdateien mit Rust unter Linux am Terminal anzeigen"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><code>bat<\/code> ist eines der neuen <a href=\"https:\/\/linux-bibel.at\/index.php\/2025\/10\/17\/die-neuen-rust-tools-unter-linux\/\" data-type=\"post\" data-id=\"20796\">Rust-Tools<\/a> unter Linux und soll als Alternative zu den Befehlen <code>less<\/code>, <code>cat<\/code>, <code>more<\/code> und <code>most<\/code> dienen. Grunds\u00e4tzlich sind die neuen Werkzeuge f\u00fcr mich selbst kein Ersatz zu den Coreutils, sondern mehr eine Alternative. Denn es ist gleich einmal so &#8211; die neuen Werkzeuge sind anders zu bedienen, k\u00f6nnen manchmal auch mehr. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In diesem Beitrag, sehen wir uns also den Befehl <code>bat<\/code> unter Linux auf dem Terminal an. Mit diesem l\u00e4sst sich der Inhalt von Textdateien aller Art auf dem Terminal anzeigen. Der Befehl hat gegen\u00fcber den genannten Befehlen einen Vorteil &#8211; die Software beherrscht Syntaxhervorhebung.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">bat installieren<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Unter auf Debian basierenden Linux-Distributionen installieren Sie diese Software durch das Paket &#8222;<strong>bat<\/strong>&#8220; &#8211; also am schnellsten als root auf dem Terminal:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt update\napt install bat<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">bat nutzen<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Grunds\u00e4tzlich einmal &#8211; unter Debian besteht schon ein Befehl namens <strong>bat<\/strong> aus einem anderen Paket, aus diesem Grund nennt sich der Befehl unter Debian nicht <code>bat<\/code>, sondern <code>batcat<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Wollen wir uns ganz einfach einmal mit dem Befehl <code>less<\/code> die Datei &#8222;<strong>.bashrc<\/strong>&#8220; ansehen:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>less .bashrc<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat.jpg\" rel=\"lightbox-0\"><img loading=\"lazy\" decoding=\"async\" width=\"866\" height=\"1024\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-866x1024.jpg\" alt=\"\" class=\"wp-image-20801\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-866x1024.jpg 866w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-127x150.jpg 127w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-254x300.jpg 254w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-768x909.jpg 768w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat.jpg 1082w\" sizes=\"auto, (max-width: 866px) 100vw, 866px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Dasselbe mit batcat:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>batcat .bashrc<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-1.jpg\" rel=\"lightbox-1\"><img loading=\"lazy\" decoding=\"async\" width=\"901\" height=\"1024\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-1-901x1024.jpg\" alt=\"\" class=\"wp-image-20802\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-1-901x1024.jpg 901w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-1-132x150.jpg 132w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-1-264x300.jpg 264w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-1-768x873.jpg 768w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-1.jpg 1126w\" sizes=\"auto, (max-width: 901px) 100vw, 901px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Die Software erkennt unter normalen Umst\u00e4nden den Code automatisch und passt die Syntaxhervorhebung dementsprechend an. Gelingt dies, aus welchem Grund auch immer, einmal nicht, k\u00f6nnen Sie die Sprache mit der Option <code>-l<\/code> oder <code>--language<\/code> an &#8211; ein Beispiel f\u00fcr Perl:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bat -l perl dateiname.pl<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Auch in bat k\u00f6nnen Sie nat\u00fcrlich mit:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/begriff<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">nach Begriffen im Text suchen, mit <kbd>Eingabe<\/kbd> best\u00e4tigen und mit <kbd>n<\/kbd> zum n\u00e4chsten Treffer springen und mit <kbd>N<\/kbd> zur\u00fcck.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Je nach Farbe des Terminals kann die Ausgabe der Syntax gut oder schlecht erkennbar sein &#8211; Sie k\u00f6nnen dies durch Themes anpassen. Mit:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>batcat --list-themes<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-2.jpg\" rel=\"lightbox-2\"><img loading=\"lazy\" decoding=\"async\" width=\"901\" height=\"1024\" src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-2-901x1024.jpg\" alt=\"\" class=\"wp-image-20803\" srcset=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-2-901x1024.jpg 901w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-2-132x150.jpg 132w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-2-264x300.jpg 264w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-2-768x873.jpg 768w, https:\/\/linux-bibel.at\/wp-content\/uploads\/2025\/10\/batcat-2.jpg 1126w\" sizes=\"auto, (max-width: 901px) 100vw, 901px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Um jetzt beispielsweise das Thema &#8222;<strong>zenburn<\/strong>&#8220; zu nutzen:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>batcat --theme=zenburn .bashrc<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\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=\"20800\" 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=\"20800\" 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>bat ist eines der neuen Rust-Tools unter Linux und soll als Alternative zu den Befehlen less, cat, more und most dienen. Grunds\u00e4tzlich sind die neuen Werkzeuge f\u00fcr mich selbst kein Ersatz zu den Coreutils, sondern mehr eine Alternative. Denn es ist gleich einmal so &#8211; die neuen Werkzeuge sind anders zu bedienen, k\u00f6nnen manchmal auch [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":20802,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[12,7,6],"class_list":["post-20800","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\/20800","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=20800"}],"version-history":[{"count":1,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts\/20800\/revisions"}],"predecessor-version":[{"id":20804,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts\/20800\/revisions\/20804"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/media\/20802"}],"wp:attachment":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/media?parent=20800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/categories?post=20800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/tags?post=20800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}