{"id":2473,"date":"2025-03-05T08:00:00","date_gmt":"2025-03-05T07:00:00","guid":{"rendered":"https:\/\/www.fuhselab.de\/?p=2473"},"modified":"2025-02-28T07:24:10","modified_gmt":"2025-02-28T06:24:10","slug":"shellskripte-4","status":"publish","type":"post","link":"https:\/\/www.fuhselab.de\/index.php\/2025\/03\/05\/shellskripte-4\/","title":{"rendered":"Shellskripte 4"},"content":{"rendered":"\n<p><br>Mit diesem Artikel geht es jetzt an die Kontrollstrukturen\u2026und auf ganz d\u00fcnnes Eis. Es werden nur einige kleine Skripte vorgestellt. Eine umfassende Einf\u00fchrung in die Shellprogrammierung kann und soll hier nicht erfolgen\u2026<\/p>\n\n\n\n<!--more-->\n\n\n\n<p><strong>Die if-else Anweisung:<\/strong><\/p>\n\n\n\n<p>Folgendes kleines Shellskript \u00fcberpr\u00fcft den Benutzernamen:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\nif test \"BENUTZER\" = \"$LOGNAME\"\nthen\necho \"Der \u00fcbergebene Name ist tats\u00e4chlich Ihr Benutzername!\"\nelse\necho \"Der \u00fcbergebene Name ist nicht Ihr Benutzername!\"\nfi\necho \"Programmende\"<\/code><\/pre>\n\n\n\n<p>Den Effekt kann man im Terminal pr\u00fcfen, wenn man einmal als Benutzer einen realen Benutzernamen im Skript eingibt und dann einen falschen Benutzer der nicht existiert\u2026<\/p>\n\n\n\n<p><strong>Die for-Schleife:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n# Name: fordemo\nfor i in eins Zwei DREI\ndo\necho $i\ndone<\/code><\/pre>\n\n\n\n<p><br><strong>Die while-Schleife:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n# Name: whiledemo\ni=1\nwhile test $i -le 5\ndo\necho $i\ni=$((i+1))\ndone<\/code><\/pre>\n\n\n\n<p><br><strong>Das readline-Skript:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n# Name: readline\nwhile read LINE\ndo\necho \"\u2013$LINE\u2013\"\ndone &lt; \/etc\/passwd<\/code><\/pre>\n\n\n\n<p><br>Die Experimente mit der Benutzerdatenbank folgen im n\u00e4chsten Artikel\u2026<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mit diesem Artikel geht es jetzt an die Kontrollstrukturen\u2026und auf ganz d\u00fcnnes Eis. Es werden nur einige kleine Skripte vorgestellt. Eine umfassende Einf\u00fchrung in die Shellprogrammierung kann und soll hier nicht erfolgen\u2026<\/p>\n","protected":false},"author":1,"featured_media":791,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[21],"class_list":["post-2473","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-linux-gruppe-peine"],"_links":{"self":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/2473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/comments?post=2473"}],"version-history":[{"count":2,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/2473\/revisions"}],"predecessor-version":[{"id":2505,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/posts\/2473\/revisions\/2505"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/media\/791"}],"wp:attachment":[{"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/media?parent=2473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/categories?post=2473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fuhselab.de\/index.php\/wp-json\/wp\/v2\/tags?post=2473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}