{"id":1970,"date":"2022-10-21T23:14:08","date_gmt":"2022-10-21T23:14:08","guid":{"rendered":"https:\/\/sunucucozumleri.com\/?p=1970"},"modified":"2022-10-19T21:23:38","modified_gmt":"2022-10-19T21:23:38","slug":"linuxta-bash-shell-komut-dosyasinda-hata-ayiklama","status":"publish","type":"post","link":"https:\/\/sunucucozumleri.com\/blog\/linuxta-bash-shell-komut-dosyasinda-hata-ayiklama\/","title":{"rendered":"Linux&#8217;ta Bash Shell Komut Dosyas\u0131nda Hata Ay\u0131klama"},"content":{"rendered":"<p>Programlama dillerinin \u00e7o\u011funda, hata ay\u0131klama i\u00e7in hata\u00a0ay\u0131klay\u0131c\u0131 arac\u0131\u00a0mevcuttur.\u00a0Hata ay\u0131klay\u0131c\u0131, bir program\u0131 veya komut dosyas\u0131n\u0131 \u00e7al\u0131\u015ft\u0131rabilen ve komut dosyas\u0131n\u0131n veya program\u0131n i\u00e7indekileri \u00e7al\u0131\u015f\u0131rken incelemenizi sa\u011flayan bir ara\u00e7t\u0131r.<\/p>\n<p>Bu yaz\u0131da, linux&#8217;ta bir bash kabuk beti\u011finde sat\u0131r sat\u0131r hata ay\u0131klamay\u0131 \u00f6\u011frenece\u011fiz.\u00a0Kabuk beti\u011finde herhangi bir hata ay\u0131klay\u0131c\u0131 arac\u0131m\u0131z yoktur, ancak\u00a0-n, -v\u00a0ve\u00a0-x\u00a0 gibi bash komut sat\u0131r\u0131 se\u00e7eneklerinin yard\u0131m\u0131yla\u00a0hata ay\u0131klamay\u0131 yapabiliriz.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Makale \u0130\u00e7eri\u011fi<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"\u0130\u00e7indekiler Tablosunu A\u00e7\/Kapat\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/sunucucozumleri.com\/blog\/linuxta-bash-shell-komut-dosyasinda-hata-ayiklama\/#Shell_Komut_Dosyasini_Sozdizimi_Hatasi_Icin_Kontrol_Etme\" >Shell Komut Dosyas\u0131n\u0131 S\u00f6zdizimi Hatas\u0131 \u0130\u00e7in Kontrol Etme<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/sunucucozumleri.com\/blog\/linuxta-bash-shell-komut-dosyasinda-hata-ayiklama\/#Kabuk_Komut_Dosyasini_Ayrintili_Modda_Calistirma\" >Kabuk Komut Dosyas\u0131n\u0131 Ayr\u0131nt\u0131l\u0131 Modda \u00c7al\u0131\u015ft\u0131rma<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/sunucucozumleri.com\/blog\/linuxta-bash-shell-komut-dosyasinda-hata-ayiklama\/#Komut_Dosyasini_-n_ve_-v_secenegiyle_calistirma\" >Komut Dosyas\u0131n\u0131 -n ve -v se\u00e7ene\u011fiyle \u00e7al\u0131\u015ft\u0131rma<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/sunucucozumleri.com\/blog\/linuxta-bash-shell-komut-dosyasinda-hata-ayiklama\/#Kabuk_Komut_Dosyasinda_Satir_Satir_Hata_Ayiklama\" >Kabuk Komut Dosyas\u0131nda Sat\u0131r Sat\u0131r Hata Ay\u0131klama<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Shell_Komut_Dosyasini_Sozdizimi_Hatasi_Icin_Kontrol_Etme\"><\/span>Shell Komut Dosyas\u0131n\u0131 S\u00f6zdizimi Hatas\u0131 \u0130\u00e7in Kontrol Etme<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Bash komutunda -n se\u00e7ene\u011fini\u00a0kullanarak beti\u011fi \u00e7al\u0131\u015ft\u0131rd\u0131\u011f\u0131m\u0131zda beti\u011fi\u00a0\u00e7al\u0131\u015ft\u0131rmayacak, beti\u011fi okuyacak ve s\u00f6zdizimini do\u011frulayacak ve varsa hatalar\u0131 bildirecektir.<span id=\"ezoic-pub-ad-placeholder-166\" class=\"ezoic-adpicker-ad\"><\/span><\/p>\n<div class=\"6DIAfz37\"><\/div>\n<p>Ba\u015fka bir deyi\u015fle, -n se\u00e7ene\u011fi, noexec\u00a0i\u00e7in shot (y\u00fcr\u00fctme yok gibi) diyebiliriz, Shell&#8217;e\u00a0komutlar\u0131 \u00e7al\u0131\u015ft\u0131rmamas\u0131n\u0131 s\u00f6yler.\u00a0Bunun yerine, kabuk yaln\u0131zca s\u00f6zdizimi hatalar\u0131n\u0131 kontrol eder.<\/p>\n<p>A\u015fa\u011f\u0131daki i\u00e7eri\u011fe sahip bir komut dosyas\u0131 olu\u015ftural\u0131m,<\/p>\n<pre>$ vi debug_quotes.sh\r\n#!\/bin\/bash\r\necho \"USER=$USER\"\r\necho \"Today's Date: $(date)\r\necho \"SHELL=$SHELL\"\r\n\r\n<\/pre>\n<p>dosyay\u0131 kaydedip kapat\u0131n.<\/p>\n<p>\u015eimdi beti\u011fi -n se\u00e7ene\u011fiyle \u00e7al\u0131\u015ft\u0131rmay\u0131 deneyin,<\/p>\n<pre>$ bash -n debug_quotes.sh\r\ndebug_quotes.sh: line 4: unexpected EOF while looking for matching `\"'\r\ndebug_quotes.sh: line 5: syntax error: unexpected end of file\r\n\r\n\r\n<\/pre>\n<p>Yukar\u0131daki \u00e7\u0131kt\u0131, s\u00f6zdizimi hatas\u0131 oldu\u011funu, \u00e7ift t\u0131rnak &#8216;\u201d&#8217; eksik oldu\u011funu g\u00f6steriyor.\u00a0Bunu d\u00fczeltmek i\u00e7in, bug\u00fcn\u00fcn tarihini g\u00f6steren sat\u0131r\u0131n sonuna \u00e7ift t\u0131rnak i\u015fareti koyun.<\/p>\n<pre><span id=\"ez-clearholder-medrectangle-3\"><\/span><img decoding=\"async\" class=\"alignnone size-full wp-image-1971\" src=\"https:\/\/sunucucozumleri.com\/wp-content\/uploads\/2022\/10\/Linuxta-Bash-Shell-Komut-Dosyasinda-Hata-Ayiklama.webp\" alt=\"\" width=\"623\" height=\"163\" title=\"\" srcset=\"\/\/sunucucozumleri.com\/blog\/wp-content\/uploads\/2022\/10\/Linuxta-Bash-Shell-Komut-Dosyasinda-Hata-Ayiklama.webp 623w, \/\/sunucucozumleri.com\/blog\/wp-content\/uploads\/2022\/10\/Linuxta-Bash-Shell-Komut-Dosyasinda-Hata-Ayiklama-300x78.webp 300w\" sizes=\"(max-width: 623px) 100vw, 623px\" \/>\r\n\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Kabuk_Komut_Dosyasini_Ayrintili_Modda_Calistirma\"><\/span>Kabuk Komut Dosyas\u0131n\u0131 Ayr\u0131nt\u0131l\u0131 Modda \u00c7al\u0131\u015ft\u0131rma<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Bash komutundaki -v se\u00e7ene\u011fi\u00a0, kabuk beti\u011fine\u00a0ayr\u0131nt\u0131l\u0131 modda\u00a0\u00e7al\u0131\u015fmas\u0131n\u0131 s\u00f6yler .\u00a0Pratikte bu, kabu\u011fun komutu \u00e7al\u0131\u015ft\u0131rmadan \u00f6nce her komutu tekrarlayaca\u011f\u0131 anlam\u0131na gelir.\u00a0Bu, \u00e7o\u011fu zaman hatalar\u0131 bulmaya yard\u0131mc\u0131 olabilece\u011fi i\u00e7in \u00e7ok kullan\u0131\u015fl\u0131d\u0131r.<\/p>\n<p>A\u015fa\u011f\u0131daki i\u00e7eri\u011fe sahip\u00a0\u201clistusers.sh\u201d\u00a0ad\u0131nda bir kabuk beti\u011fi yapal\u0131m ,<\/p>\n<pre>$ vi listusers.sh#!\/bin\/bash\r\ncut -d : -f1,5,7 \/etc\/passwd | grep -v sbin | grep sh | sort &gt; \/tmp\/users.txt\r\nawk -F':' ' { printf ( \"%-12s %-40s\\n\", $1, $2 ) } ' \/tmp\/users.txt\r\n\r\n#Clean up the temporary file.\r\n\/bin\/rm -f \/tmp\/users.txt\r\n\r\n<\/pre>\n<p>Komut dosyas\u0131n\u0131 -v se\u00e7ene\u011fiyle y\u00fcr\u00fct\u00fcn,<\/p>\n<pre>bash -v listusers.sh<\/pre>\n<p>\u00e7\u0131kt\u0131,<\/p>\n<pre><img decoding=\"async\" class=\"alignnone size-full wp-image-1972\" style=\"font-family: Georgia, &#039;Times New Roman&#039;, &#039;Bitstream Charter&#039;, Times, serif; white-space: normal;\" src=\"https:\/\/sunucucozumleri.com\/wp-content\/uploads\/2022\/10\/Linuxta-Bash-Shell-Komut-Dosyasinda-Hata-Ayiklama2.webp\" alt=\"\" width=\"768\" height=\"227\" title=\"\" srcset=\"\/\/sunucucozumleri.com\/blog\/wp-content\/uploads\/2022\/10\/Linuxta-Bash-Shell-Komut-Dosyasinda-Hata-Ayiklama2.webp 768w, \/\/sunucucozumleri.com\/blog\/wp-content\/uploads\/2022\/10\/Linuxta-Bash-Shell-Komut-Dosyasinda-Hata-Ayiklama2-300x89.webp 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/>\r\n\r\n<\/pre>\n<p>Yukar\u0131daki \u00e7\u0131kt\u0131da, komut dosyas\u0131 \u00e7\u0131kt\u0131s\u0131, komut dosyalar\u0131n\u0131n komutlar\u0131yla kar\u0131\u015ft\u0131r\u0131l\u0131r.\u00a0Ancak\u00a0-v se\u00e7ene\u011fiyle\u00a0, en az\u0131ndan beti\u011finizi \u00e7al\u0131\u015ft\u0131r\u0131rken kabu\u011fun ne yapt\u0131\u011f\u0131na dair daha iyi bir g\u00f6r\u00fc\u015f elde edersiniz.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Komut_Dosyasini_-n_ve_-v_secenegiyle_calistirma\"><\/span>Komut Dosyas\u0131n\u0131 -n ve -v se\u00e7ene\u011fiyle \u00e7al\u0131\u015ft\u0131rma<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Komut sat\u0131r\u0131 se\u00e7eneklerini ( -n &amp; -v ) birle\u015ftirebiliriz.\u00a0Bu, komut dosyas\u0131 \u00e7\u0131kt\u0131s\u0131n\u0131 g\u00f6r\u00fcnt\u00fclerken bir komut dosyas\u0131n\u0131n s\u00f6zdizimini kontrol edebildi\u011fimiz i\u00e7in iyi bir kombinasyon olu\u015fturur.<\/p>\n<p>Daha \u00f6nce kullan\u0131lan\u00a0\u201cdebug_quotes.sh\u201d beti\u011fini ele alal\u0131m.<\/p>\n<pre>$ bash -nv debug_quotes.sh\r\n#!\/bin\/bash\r\necho \"USER=$USER\"\r\necho \"Today's Date: $(date)\r\necho \"SHELL=$SHELL\"\r\ndebug_quotes.sh: line 4: unexpected EOF while looking for matching `\"'\r\ndebug_quotes.sh: line 5: syntax error: unexpected end of file\r\n\r\n\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Kabuk_Komut_Dosyasinda_Satir_Satir_Hata_Ayiklama\"><\/span>Kabuk Komut Dosyas\u0131nda Sat\u0131r Sat\u0131r Hata Ay\u0131klama<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>xtrace\u00a0veya\u00a0y\u00fcr\u00fctme izlemesinin\u00a0k\u0131saltmas\u0131 olan\u00a0-x se\u00e7ene\u011fi\u00a0,\u00a0kabuk de\u011fi\u015ftirme ad\u0131mlar\u0131n\u0131 ger\u00e7ekle\u015ftirdikten sonra her komutu yank\u0131lamas\u0131n\u0131 s\u00f6yler.\u00a0B\u00f6ylece de\u011fi\u015fkenlerin ve komutlar\u0131n de\u011ferlerini g\u00f6rebiliriz.\u00a0\u00c7o\u011fu zaman, bu se\u00e7enek tek ba\u015f\u0131na bir sorunu te\u015fhis etmeye yard\u0131mc\u0131 olur.<\/p>\n<p>\u00c7o\u011fu durumda, -x se\u00e7ene\u011fi bir komut dosyas\u0131 hakk\u0131nda en yararl\u0131 bilgileri sa\u011flar, ancak \u00e7ok fazla \u00e7\u0131kt\u0131ya yol a\u00e7abilir.\u00a0A\u015fa\u011f\u0131daki \u00f6rnek, bu se\u00e7ene\u011fi \u00e7al\u0131\u015f\u0131rken g\u00f6stermektedir.<\/p>\n<p>&nbsp;<\/p>\n<pre>$ bash -x listusers.sh\r\n+ sort\r\n+ grep sh\r\n+ grep -v sbin\r\n+ cut -d : -f1,5,7 \/etc\/passwd\r\n+ awk -F: ' { printf ( \"%-12s %-40s\\n\", $1, $2 ) } ' \/tmp\/users.txt\r\nlinuxtechi linuxtechi,,,\r\nroot root\r\n+ \/bin\/rm -f \/tmp\/users.txt\r\n<\/pre>\n<p>G\u00f6rd\u00fc\u011f\u00fcm\u00fcz gibi, kabuk her komutun \u00f6n\u00fcne bir + i\u015fareti eklemi\u015ftir.<\/p>\n<p>Hepsi bu g\u00f6nderiden.\u00a0Bilgilendirici ve faydal\u0131 buldum.\u00a0L\u00fctfen sorular\u0131n\u0131z\u0131 ve g\u00f6r\u00fc\u015flerinizi a\u015fa\u011f\u0131daki yorumlar b\u00f6l\u00fcm\u00fcne g\u00f6ndermekten \u00e7ekinmeyin.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Programlama dillerinin \u00e7o\u011funda, hata ay\u0131klama i\u00e7in hata\u00a0ay\u0131klay\u0131c\u0131 arac\u0131\u00a0mevcuttur.\u00a0Hata ay\u0131klay\u0131c\u0131, bir program\u0131 veya komut dosyas\u0131n\u0131 \u00e7al\u0131\u015ft\u0131rabilen ve komut dosyas\u0131n\u0131n veya program\u0131n i\u00e7indekileri \u00e7al\u0131\u015f\u0131rken incelemenizi sa\u011flayan bir ara\u00e7t\u0131r. Bu yaz\u0131da, linux&#8217;ta bir bash kabuk beti\u011finde sat\u0131r sat\u0131r hata ay\u0131klamay\u0131 \u00f6\u011frenece\u011fiz.\u00a0Kabuk beti\u011finde herhangi bir hata ay\u0131klay\u0131c\u0131 arac\u0131m\u0131z yoktur, ancak\u00a0-n, -v\u00a0ve\u00a0-x\u00a0 gibi bash komut sat\u0131r\u0131 se\u00e7eneklerinin yard\u0131m\u0131yla\u00a0hata ay\u0131klamay\u0131 yapabiliriz. &hellip;<\/p>\n","protected":false},"author":1,"featured_media":1972,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1970","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"acf":[],"_links":{"self":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/posts\/1970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/comments?post=1970"}],"version-history":[{"count":0,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/posts\/1970\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/media\/1972"}],"wp:attachment":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/media?parent=1970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/categories?post=1970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/tags?post=1970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}