{"id":4202,"date":"2019-04-23T21:55:57","date_gmt":"2019-04-23T17:25:57","guid":{"rendered":"https:\/\/rasanegar.com\/blog\/?p=4202"},"modified":"2019-04-26T01:08:46","modified_gmt":"2019-04-25T20:38:46","slug":"learn-bash-script-with-30-example","status":"publish","type":"post","link":"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/","title":{"rendered":"30 \u0646\u0645\u0648\u0646\u0647 \u062f\u0633\u062a\u0648\u0631 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a Bash &#8211; \u06cc\u0627\u062f\u06af\u06cc\u0631\u06cc \u0628\u0634 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0628\u0627 \u0646\u0645\u0648\u0646\u0647"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">\u0633\u0631\u0641\u0635\u0644\u0647\u0627\u06cc \u0645\u0637\u0644\u0628<\/p>\n<\/div><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:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%db%8c%d8%ac%d8%a7%d8%af_%d9%88_%d8%a7%d8%ac%d8%b1%d8%a7%db%8c_%d8%a7%d9%88%d9%84%db%8c%d9%86_%d8%a8%d8%b1%d9%86%d8%a7%d9%85%d9%87_bash_%e2%80%93_hello_world\" >\u0627\u06cc\u062c\u0627\u062f \u0648 \u0627\u062c\u0631\u0627\u06cc \u0627\u0648\u0644\u06cc\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 BASH &#8211; Hello World<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%af%d8%b3%d8%aa%d9%88%d8%b1_echo\" >\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062f\u0633\u062a\u0648\u0631 echo<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#comment_%da%a9%d8%b1%d8%af%d9%86_%da%a9%d8%af_%d8%af%d8%b1_bash_script\" >comment \u06a9\u0631\u062f\u0646 \u06a9\u062f \u062f\u0631 Bash Script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%da%a9%d8%a7%d9%85%d9%86%d8%aa_%da%a9%d8%b1%d8%af%d9%86_%da%86%d9%86%d8%af_%d8%ae%d8%b7_%d8%af%d8%b1_bash_scripting\" >\u06a9\u0627\u0645\u0646\u062a \u06a9\u0631\u062f\u0646 \u0686\u0646\u062f \u062e\u0637 \u062f\u0631 Bash Scripting<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%ad%d9%84%d9%82%d9%87_while_%d8%af%d8%b1_bash_script\" >\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062d\u0644\u0642\u0647 While \u062f\u0631 Bash Script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%ad%d9%84%d9%82%d9%87_for_%d8%af%d8%b1_bash_script\" >\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062d\u0644\u0642\u0647 FOR \u062f\u0631 Bash Script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%da%af%d8%b1%d9%81%d8%aa%d9%86_%d9%88%d8%b1%d9%88%d8%af%db%8c_%d8%a7%d8%b2_%da%a9%d8%a7%d8%b1%d8%a8%d8%b1_%d8%af%d8%b1_bash_script\" >\u06af\u0631\u0641\u062a\u0646 \u0648\u0631\u0648\u062f\u06cc \u0627\u0632 \u06a9\u0627\u0631\u0628\u0631 \u062f\u0631 Bash Script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%b4%d8%b1%d8%b7_if_%d8%af%d8%b1_bash_script\" >\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0634\u0631\u0637 if \u062f\u0631 Bash Script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%aa%d8%b9%d8%b1%db%8c%d9%81_if_%d9%88_%d9%85%d9%86%d8%b7%d9%82_and_%d8%af%d8%b1_bash_scripting\" >\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u0639\u0631\u06cc\u0641 IF \u0648 \u0645\u0646\u0637\u0642 AND \u062f\u0631 Bash Scripting<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%aa%d8%b9%d8%b1%db%8c%d9%81_if_%d9%88_%d9%85%d9%86%d8%b7%d9%82_or_%d8%af%d8%b1_bash_scripting\" >\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u0639\u0631\u06cc\u0641 IF \u0648 \u0645\u0646\u0637\u0642 OR \u062f\u0631 Bash Scripting<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%aa%d8%b9%d8%b1%db%8c%d9%81_%d8%b4%d8%b1%d8%b7_if_%d8%af%d8%b1_shell_scripting\" >\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u0639\u0631\u06cc\u0641 \u0634\u0631\u0637 IF \u062f\u0631 Shell Scripting<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%aa%d8%b9%d8%b1%db%8c%d9%81_case\" >\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u0639\u0631\u06cc\u0641 Case<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%da%af%d8%b1%d9%81%d8%aa%d9%86_%d8%a2%d8%b1%da%af%d9%88%d9%85%d8%a7%d9%86_%d8%a7%d8%b2_%d8%ae%d8%b7_%d9%81%d8%b1%d9%85%d8%a7%d9%86\" >\u06af\u0631\u0641\u062a\u0646 \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0627\u0632 \u062e\u0637 \u0641\u0631\u0645\u0627\u0646<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%da%af%d8%b1%d9%81%d8%aa%d9%86_%d8%a2%d8%b1%da%af%d9%88%d9%85%d8%a7%d9%86_%d8%a7%d8%b2_%d8%ae%d8%b7_%d9%81%d8%b1%d9%85%d8%a7%d9%86_%d8%a8%d8%a7_%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d9%86%d8%a7%d9%85_%d9%87%d8%a7\" >\u06af\u0631\u0641\u062a\u0646 \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0627\u0632 \u062e\u0637 \u0641\u0631\u0645\u0627\u0646 \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0646\u0627\u0645 \u0647\u0627<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%aa%d8%b1%da%a9%db%8c%d8%a8_%d9%85%d8%aa%d8%ba%db%8c%d8%b1%d9%87%d8%a7%db%8c_%d8%b1%d8%b4%d8%aa%d9%87%e2%80%8e%d8%a7%db%8c\" >\u062a\u0631\u06a9\u06cc\u0628 \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc \u0631\u0634\u062a\u0647\u200e\u0627\u06cc<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%af%d8%b1%db%8c%d8%a7%d9%81%d8%aa_%d8%b2%db%8c%d8%b1%d8%b1%d8%b4%d8%aa%d9%87_%d8%a7%d8%b2_%db%8c%da%a9_%d8%b1%d8%b4%d8%aa%d9%87\" >\u062f\u0631\u06cc\u0627\u0641\u062a \u0632\u06cc\u0631\u0631\u0634\u062a\u0647 \u0627\u0632 \u06cc\u06a9 \u0631\u0634\u062a\u0647:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%ac%d9%85%d8%b9_%d8%af%d9%88_%d8%b9%d8%af%d8%af\" >\u062c\u0645\u0639 \u062f\u0648 \u0639\u062f\u062f:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%db%8c%d8%ac%d8%a7%d8%af_%d8%aa%d8%a7%d8%a8%d8%b9\" >\u0627\u06cc\u062c\u0627\u062f \u062a\u0627\u0628\u0639<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%db%8c%d8%ac%d8%a7%d8%af_%d8%aa%d8%a7%d8%a8%d8%b9_%d8%a8%d8%a7_%d9%be%d8%a7%d8%b1%d8%a7%d9%85%d8%aa%d8%b1%d9%87%d8%a7\" >\u0627\u06cc\u062c\u0627\u062f \u062a\u0627\u0628\u0639 \u0628\u0627 \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#%d8%a7%d8%b1%d8%ac%d8%a7%d8%b9_return_value_%d8%af%d8%b1_funtion\" >\u0627\u0631\u062c\u0627\u0639 Return Value \u062f\u0631 Funtion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#make_directory\" >Make Directory:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#make_directory_by_checking_existence\" >Make directory by checking existence:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#read_a_file\" >Read a File:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#delete_a_file\" >Delete a File:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#append_to_file\" >Append to File:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#test_if_file_exist\" >Test if File Exist:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#send_email\" >Send Email:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#get_parse_current_date\" >Get Parse Current Date:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#wait_command\" >Wait Command:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/rasanegaar.com\/blog\/learn-bash-script-with-30-example\/#sleep_command\" >Sleep Command:<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">\u0632\u0645\u0627\u0646 \u0644\u0627\u0632\u0645 \u0628\u0631\u0627\u06cc \u0645\u0637\u0627\u0644\u0639\u0647: <\/span> <span class=\"rt-time\"> 12<\/span> <span class=\"rt-label rt-postfix\">\u062f\u0642\u06cc\u0642\u0647<\/span><\/span><p><main id=\"main\"><\/p>\n<article id=\"post-28307\">\n<div>\n<div>\u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0646\u0648\u06cc\u0633\u06cc \u0628\u0634 (Bash) \u0645\u06cc\u200e\u062a\u0648\u0627\u0646\u062f \u0628\u0631\u0627\u06cc \u0645\u0648\u0627\u0631\u062f \u0632\u06cc\u0627\u062f\u06cc \u0627\u0632 \u062c\u0645\u0644\u0647 \u0627\u062c\u0631\u0627\u06cc \u062f\u0633\u062a\u0648\u0631 Shell \u060c \u0627\u062c\u0631\u0627\u06cc \u0686\u0646\u062f\u06cc\u0646 \u062f\u0633\u062a\u0648\u0631 \u0628\u0627 \u0647\u0645 \u060c \u0633\u0641\u0627\u0631\u0634\u06cc \u0633\u0627\u0632\u06cc \u0648\u0638\u0627\u06cc\u0641 \u0645\u062f\u06cc\u0631\u06cc\u062a\u06cc \u060c \u0627\u062c\u0631\u0627\u06cc \u062a\u0633\u06a9 \u0647\u0627 \u0628\u0635\u0648\u0631\u062a \u0627\u062a\u0648\u0645\u0627\u062a\u06cc\u06a9 \u0648 &#8230; \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0634\u0648\u062f \u0628\u0647 \u0647\u0645\u06cc\u0646 \u062f\u0644\u06cc\u0644 \u062f\u0627\u0646\u0634 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc Bash \u0648 \u067e\u0627\u06cc\u0647 \u0622\u0646 \u0628\u0631\u0627\u06cc \u0647\u0631 \u06a9\u0627\u0631\u0628\u0631 \u0633\u06cc\u0633\u062a\u0645 \u0639\u0627\u0645\u0644 \u0644\u06cc\u0646\u0648\u06a9\u0633 \u0645\u0647\u0645 \u0627\u0633\u062a \u060c<\/div>\n<div>\u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647 \u0628\u0647 \u0634\u0645\u0627 \u06a9\u0645\u06a9 \u0645\u06cc\u06a9\u0646\u062f \u062a\u0627 \u0627\u06cc\u062f\u0647 \u067e\u0627\u06cc\u0647 \u0627\u06cc \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc \u0628\u0634 \u0622\u0634\u0646\u0627 \u0634\u0648\u06cc\u062f \u060c\u0628\u0633\u06cc\u0627\u0631\u06cc \u0627\u0632 \u0639\u0645\u0644\u06cc\u0627\u062a \u0631\u0627\u06cc\u062c \u062f\u0631 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0646\u0648\u06cc\u0633\u06cc Bash \u0628\u0627 \u0645\u062b\u062a\u0627\u0644\u0647\u0627\u06cc \u0633\u0627\u062f\u0647 \u0631\u0627 \u062a\u0648\u0635\u06cc\u062d \u062e\u0648\u0627\u0647\u06cc\u0645 \u062f\u0627\u062f<\/div>\n<div>\u0633\u0631\u0641\u0635\u0644\u0647\u0627\u06cc \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647 \u0645\u0631\u0648\u0631 \u062e\u0648\u0627\u0647\u06cc\u0645 \u06a9\u0631\u062f.<\/div>\n<div><\/div>\n<\/div>\n<\/article>\n<p><\/main><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%d8%a7%db%8c%d8%ac%d8%a7%d8%af_%d9%88_%d8%a7%d8%ac%d8%b1%d8%a7%db%8c_%d8%a7%d9%88%d9%84%db%8c%d9%86_%d8%a8%d8%b1%d9%86%d8%a7%d9%85%d9%87_bash_%e2%80%93_hello_world\"><\/span>\u0627\u06cc\u062c\u0627\u062f \u0648 \u0627\u062c\u0631\u0627\u06cc \u0627\u0648\u0644\u06cc\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 BASH &#8211; Hello World<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u0634\u0645\u0627 \u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a Bash \u0631\u0627 \u0628\u0627 \u0627\u062c\u0631\u0627\u06cc \u06cc\u06a9 \u0641\u0627\u06cc\u0644 Bash \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f \u060c \u062f\u0633\u062a\u0648\u0631 \u0632\u06cc\u0631 \u0631\u0627 \u0631 \u062a\u0631\u0645\u06cc\u0646\u0627\u0644 \u0633\u06cc\u0633\u062a\u0645 \u062e\u0648\u062f \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f \u062a\u0627 \u06cc\u06a9 \u062e\u0631\u0648\u062c\u06cc \u0628\u0633\u06cc\u0627\u0631 \u0633\u0627\u062f\u0647 \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0646\u06cc\u062f \u060c \u062e\u0631\u0648\u062c\u06cc \u062f\u0633\u062a\u0648\u0631 \u0632\u06cc\u0631 &#8220;Hello World&#8221; \u062e\u0648\u0627\u0647\u062f \u0628\u0648\u062f<\/p>\n<p><main id=\"main\"><\/p>\n<article id=\"post-28307\">\n<div>\n<div id=\"wpbody\">\n<div>\n<pre class=\"\">$ echo \"Hello World\"<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h.png\" sizes=\"(max-width: 737px) 100vw, 737px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h.png 737w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h-300x30.png 300w\" alt=\"\" width=\"737\" height=\"73\" title=\"\"><\/p>\n<p>\u0627\u062f\u06cc\u062a\u0648\u0631 \u0645\u062d\u0628\u0648\u0628 \u062e\u0648\u062f \u0631\u0627 \u0628\u0627\u0632 \u06a9\u0646\u06cc\u062f \u060c \u0645\u0627 \u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u0627\u0632 nano \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200e\u06a9\u0646\u06cc\u0645 \u060c \u0627\u0633\u0645 \u0641\u0627\u06cc\u0644 \u0627 First.sh \u0645\u06cc\u06af\u0630\u0627\u0631\u06cc\u0645<\/p>\n<div>\n<pre class=\"\">nano First.sh<\/pre>\n<\/div>\n<p>\u062f\u0633\u062a\u0648\u0631\u0627\u062a \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0641\u0627\u06cc\u0644 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\necho \"Hello World\"<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h1.png\" sizes=\"(max-width: 731px) 100vw, 731px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h1.png 731w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h1-300x67.png 300w\" alt=\"\" width=\"731\" height=\"163\" title=\"\"><\/p>\n<p>\u0627\u062c\u0631\u0627\u06cc \u0641\u0627\u06cc\u0644 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0628\u0634 \u0627\u0632 \u062f\u0648 \u0637\u0631\u06cc\u0642 \u0627\u0645\u06a9\u0627\u0646 \u067e\u0630\u06cc\u0631 \u0627\u0633\u062a \u060c \u06cc\u06cc \u0628\u0627 \u0627\u062c\u0631\u0627\u06cc \u062f\u0633\u062a\u0648\u0631 \u0648 \u062f\u06cc\u06af\u0631\u06cc \u0633\u062a \u06a9\u0631\u062f\u0646 \u062f\u0633\u062a\u0631\u0633\u06cc \u0627\u062c\u0631\u0627 \u06cc\u0627 execute \u0631\u0648\u06cc \u0641\u0627\u06cc\u0644 bash \u0648 \u0627\u062c\u0631\u0627\u06cc \u0641\u0627\u06cc\u0644 \u0627\u0633\u062a \u060c \u0647\u0631 \u062f\u0648 \u0631\u0648\u0634 \u0631\u0627 \u0627\u06cc\u0646\u062c\u0627 \u0646\u0634\u0627\u0646 \u062e\u0648\u0627\u0647\u0645 \u062f\u0627\u062f<\/p>\n<div>\n<pre class=\"\">$ bash First.sh<\/pre>\n<\/div>\n<p>\u06cc\u0627<\/p>\n<div>\n<pre class=\"\">$ chmod a+x First.sh\r\n$ .\/First.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h2.png\" sizes=\"(max-width: 733px) 100vw, 733px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h2.png 733w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h2-300x52.png 300w\" alt=\"\" width=\"733\" height=\"126\" title=\"\"><\/p>\n<p><a href=\".#TOP\" class=\"broken_link\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%af%d8%b3%d8%aa%d9%88%d8%b1_echo\"><\/span>\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062f\u0633\u062a\u0648\u0631 echo<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0634\u0645\u0627 \u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u062f\u0633\u062a\u0648\u0631 echo \u0631\u0627 \u0628\u0627 \u06af\u0632\u06cc\u0646\u0647 \u0647\u0627\u06cc \u0645\u062e\u062a\u0644\u0641\u06cc \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f \u060c \u0628\u0631\u062e\u06cc \u06af\u0632\u06cc\u0646\u0647 \u0647\u0627\u06cc \u06a9\u0627\u0631\u0628\u0631\u06cc \u0622\u0646 \u0631\u0627 \u062f\u0631 \u062f\u0631 \u0645\u062b\u0627\u0644 \u0632\u06cc\u0631 \u0630\u06a9\u0631 \u06a9\u0631\u062f\u06cc\u0645 \u060c \u0648\u0642\u062a\u06cc \u0627\u0632 &#8220;echo &#8221; \u0628\u062f\u0648\u0646 \u0647\u06cc\u0686 \u0622\u067e\u0634\u0646\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f \u06cc\u06a9 \u062e\u0637 \u062c\u062f\u06cc\u062f \u0628\u0635\u0648\u0631\u062a \u067e\u06cc\u0634\u0641\u0631\u0636 \u0627\u0636\u0627\u0641\u0647 \u0645\u06cc\u200e\u0634\u0648\u062f \u060c \u06af\u0632\u06cc\u0646\u0647 &#8216;-n&#8217; \u0628\u0631\u0627\u06cc \u0646\u0645\u0627\u06cc\u0634 \u0647\u0631 \u0645\u062a\u0646\u06cc \u0628\u062f\u0648\u0646 \u06cc\u06a9 \u062e\u0637 \u062c\u062f\u06cc\u062f \u0648 -e \u0628\u0631\u0627\u06cc \u062d\u0630\u0641 \u067e\u06a9 \u0627\u0633\u0644\u0634 \u06cc\u0627 \\ \u0627\u0632 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627\u06cc \u062e\u0631\u0648\u062c\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 bash \u062c\u062f\u06cc\u062f \u0628\u0647 \u0627\u0633\u0645 echo_example.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0622\u0646 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f<\/p>\n<pre class=\"\" dir=\"ltr\">#!\/bin\/bash\r\necho \"Printing text with newline\"\r\necho -n \"Printing text without newline\"\r\necho -e \"\\nRemoving \\t backslash \\t characters\\n\"<\/pre>\n<\/div>\n<\/div>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 bash \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<div>\n<div id=\"wpbody\">\n<div>\n<pre class=\"\">$ bash echo_example.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h3.png\" sizes=\"(max-width: 732px) 100vw, 732px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h3.png 732w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h3-300x52.png 300w\" alt=\"\" width=\"732\" height=\"128\" title=\"\"><\/p>\n<p><a href=\".#TOP\" class=\"broken_link\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"comment_%da%a9%d8%b1%d8%af%d9%86_%da%a9%d8%af_%d8%af%d8%b1_bash_script\"><\/span>comment \u06a9\u0631\u062f\u0646 \u06a9\u062f \u062f\u0631 Bash Script<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0639\u0644\u0627\u0645\u062a &#8216;#&#8217; \u0628\u0631\u0627\u06cc \u06a9\u0627\u0645\u0646\u062a \u06a9\u0631\u062f\u0646 \u06cc\u06a9 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u0623 \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u062c\u062f\u06cc\u062f \u0628\u0627 \u0646\u0627\u0645 comment_script.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0622\u0646 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f \u060c \u06a9\u0647 \u062d\u0627\u0648\u06cc \u06cc\u06a9 \u062e\u0637 \u06a9\u0627\u0645\u0646\u062a \u0634\u062f\u0647 \u0627\u0633\u062a<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\n# Add two numeric value\r\n((sum=25+35))\r\n#Print the result\r\necho $sum<\/pre>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 bash \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<div id=\"wpbody\">\n<div>\n<pre class=\"\">$ bash comment_example.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h4.png\" sizes=\"(max-width: 732px) 100vw, 732px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h4.png 732w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h4-300x30.png 300w\" alt=\"\" width=\"732\" height=\"72\" title=\"\"><\/p>\n<p><a href=\".#TOP\" class=\"broken_link\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%da%a9%d8%a7%d9%85%d9%86%d8%aa_%da%a9%d8%b1%d8%af%d9%86_%da%86%d9%86%d8%af_%d8%ae%d8%b7_%d8%af%d8%b1_bash_scripting\"><\/span>\u06a9\u0627\u0645\u0646\u062a \u06a9\u0631\u062f\u0646 \u0686\u0646\u062f \u062e\u0637 \u062f\u0631 Bash Scripting<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0634\u0645\u0627 \u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u0686\u0646\u062f\u06cc\u0646 \u062e\u0637 \u0627\u0632 \u06a9\u062f \u0631\u0627 \u062f\u0631 \u0628\u0634 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a\u06cc\u0646\u06af \u06a9\u0627\u0645\u0646\u062a \u06a9\u0646\u06cc\u062f \u060c\u0631\u0627\u0647 \u0633\u0627\u062f\u0647 \u0627\u06cc \u06a9\u0647 \u062f\u0631 \u0645\u062b\u0627\u0644 \u0632\u06cc\u0631 \u0628\u0647 \u0622\u0646 \u0627\u0634\u0627\u0631\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u062c\u062f\u06cc\u062f \u0628\u0627 \u0646\u0627\u0646 multiline_comment.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0622\u0646 \u06a9\u067e\u06cc \u06a9\u0646\u06cc\u062f\u060c \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0628\u0631\u0627\u06cc \u0645\u062d\u0627\u0633\u0628\u0647 \u0645\u0631\u0628\u0639 \u0639\u062f\u062f 5 \u0645\u06cc \u0628\u0627\u0634\u062f<\/p>\n<p>You can use multi line comment in bash in various ways. A simple way is shown in the following example. Create a new bash named, \u2018multiline-comment.sh\u2019 and add the following script. Here, \u2018:\u2019 and \u201c \u2019 \u201d symbols are used to add multiline comment in bash script. This following script will calculate the square of 5.<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\n: '\r\nThe following script calculates\r\nthe square value of the number, 5.\r\n'\r\n((area=5*5))\r\necho $area<\/pre>\n<\/div>\n<div>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u062f\u0633\u062a\u0648\u0631 bash \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/div>\n<div>\u00a0<\/div>\n<\/div>\n<\/div>\n<div>\n<div id=\"wpbody\">\n<div>\n<pre class=\"\">$ bash multiline-comment.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h5.png\" sizes=\"(max-width: 734px) 100vw, 734px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h5.png 734w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h5-300x30.png 300w\" alt=\"\" width=\"734\" height=\"74\" title=\"\"><\/p>\n<p>\u0628\u0631\u0627\u06cc \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631 \u062f\u0631 \u062e\u0635\u0648\u0635 \u06a9\u0627\u0645\u0646\u062a \u06a9\u0631\u062f\u0646 \u06a9\u062f \u062f\u0631 bash \u0628\u0647 \u0644\u06cc\u0646\u06a9 \u0632\u06cc\u0631 \u0645\u0631\u0627\u062c\u0639\u0647 \u06a9\u0646\u06cc\u062f<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/bash_comments\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https:\/\/linuxhint.com\/bash_comments\/<\/a><\/p>\n<p><a href=\".#TOP\" class=\"broken_link\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%ad%d9%84%d9%82%d9%87_while_%d8%af%d8%b1_bash_script\"><\/span>\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062d\u0644\u0642\u0647 While \u062f\u0631 Bash Script<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0634 \u0628\u0627 \u0627\u0633\u0645 while_example.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u062a\u0627 \u0628\u0628\u0646\u06cc\u062f \u06a9\u0647 \u062d\u0644\u0642\u0647 while \u0628\u0647 \u0686\u0647 \u0634\u06a9\u0644 \u06a9\u0627\u0631 \u0645\u06cc \u06a9\u0646\u062f \u060c\u00a0 \u062f\u0631 \u0627\u06cc\u0646 \u0645\u062b\u0627\u0644 \u062d\u0644\u0642\u0647\u00a0 While 5 \u0628\u0627\u0631 \u062a\u06a9\u0631\u0627\u0631 \u0645\u06cc \u0634\u0648\u062f \u060c \u0645\u0642\u062f\u0627\u0631 \u0645\u062a\u063a\u06cc\u0631 count \u0628\u0647 \u0627\u0632\u0627\u06cc \u0647\u0631 \u06af\u0627\u0645 \u0628\u0647 \u0627\u0646\u062f\u0627\u0632\u0647 1 \u0648\u0627\u062e\u062f \u0627\u0641\u0632\u0627\u06cc\u0634 \u067e\u06cc\u062f\u0627 \u0645\u06cc \u06a9\u0646\u062f \u0648 \u0628\u0639\u062f \u0627\u0632 \u0631\u0633\u06cc\u062f\u0646 \u0645\u0642\u062f\u0627\u0631 \u0645\u062a\u063a\u06cc\u0631 count \u0628\u0647 5 \u062d\u0644\u0642\u0647 \u067e\u0627\u06cc\u0627\u0646 \u0645\u06cc \u06cc\u0627\u0628\u062f<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\nvalid=true\r\ncount=1\r\nwhile [ $valid ]\r\ndo\r\necho $count\r\nif [ $count -eq 5 ];\r\nthen\r\nbreak\r\nfi\r\n((count++))\r\ndone<\/pre>\n<div>\u00a0<\/div>\n<\/div>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648 \u0632\u06cc\u0631 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<div>\n<pre class=\"\">$ bash while_example.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h6.png\" sizes=\"(max-width: 730px) 100vw, 730px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h6.png 730w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h6-300x54.png 300w\" alt=\"\" width=\"730\" height=\"131\" title=\"\"><\/p>\n<p>\u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0632 \u0637\u0631\u06cc\u0642 \u0644\u06cc\u0646\u06a9 \u0632\u06cc\u0631 \u062f\u0631 \u0645\u0648\u0631\u062f \u062f\u0633\u062a\u0648\u0631 while \u062f\u0631 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0646\u0648\u06cc\u0633\u06cc Bash \u0628\u06cc\u0634\u062a\u0631 \u06cc\u0627\u062f \u0628\u06af\u06cc\u0631\u06cc\u062f .<\/p>\n<p dir=\"ltr\"><a href=\"https:\/\/linuxhint.com\/bash-while-loop-examples\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"broken_link\">https:\/\/linuxhint.com\/bash-while-loop-examples\/<\/a><\/p>\n<p><a href=\".#TOP\" class=\"broken_link\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%ad%d9%84%d9%82%d9%87_for_%d8%af%d8%b1_bash_script\"><\/span>\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062d\u0644\u0642\u0647 FOR \u062f\u0631 Bash Script<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0627\u0635\u0648\u0644 \u062a\u0639\u0631\u06cc\u0641 \u062d\u0644\u0642\u0647 \u062f\u0631 \u0645\u062b\u0627\u0644 \u0632\u06cc\u0631 \u0622\u0648\u0631\u062f\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0627\u0633\u0645 for_examamples.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0622\u0646 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f \u060c \u062d\u0644\u0642\u0647 for \u0632\u06cc\u0631 \u0628\u0631\u0627\u06cc 10 \u0628\u0627\u0631 \u062a\u06a9\u0631\u0627\u0631 \u0634\u062f\u0647 \u0648 \u0647\u0645\u0647 \u0645\u0642\u0627\u062f\u06cc\u0631 \u0645\u062a\u063a\u06cc\u0631 \u0631\u0627 \u0646\u0645\u0627\u06cc\u0634 \u0645\u06cc\u062f\u0647\u062f \u060c counter \u062f\u0631 \u06cc \u06cc\u06a9 \u062e\u0637 \u062e\u0648\u0627\u0647\u062f \u0628\u0648\u062f<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\nfor (( counter=10; counter&gt;0; counter-- ))\r\ndo\r\necho -n \"$counter \"\r\ndone\r\nprintf \"\\n\"<\/pre>\n<\/div>\n<\/div>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0632 \u0632\u06cc\u0631 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<div id=\"wpbody\">\n<div>\n<pre class=\"\">$ bash for_example.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h7.png\" sizes=\"(max-width: 730px) 100vw, 730px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h7.png 730w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h7-300x28.png 300w\" alt=\"\" width=\"730\" height=\"69\" title=\"\"><\/p>\n<p>\u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0632 \u062f\u0633\u062a\u0648\u0631 \u062d\u0644\u0642\u0647 for \u0628\u0631\u0627\u06cc \u06a9\u0627\u0631\u0628\u0631\u062f\u0647\u0627\u06cc \u0645\u062e\u062a\u0644\u0641 \u0628\u0647 \u0631\u0648\u0634\u0647\u0627\u06cc \u0645\u062e\u062a\u0644\u0641 \u062f\u0631 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u062e\u0648\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f \u060c \u0644\u06cc\u0646\u06a9 \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0631\u0627\u06cc \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631 \u062f\u0631\u062e\u0635\u0648\u0635 \u062d\u0644\u0642\u0647 for \u0628\u0631\u0631\u0633\u06cc \u06a9\u0646\u06cc\u062f<\/p>\n<p dir=\"ltr\"><a href=\"https:\/\/linuxhint.com\/bash-for-loop-examples\/\" target=\"_blank\" rel=\"noopener\">https:\/\/linuxhint.com\/bash-for-loop-examples\/<\/a><\/p>\n<p><a href=\".#TOP\" class=\"broken_link\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%da%af%d8%b1%d9%81%d8%aa%d9%86_%d9%88%d8%b1%d9%88%d8%af%db%8c_%d8%a7%d8%b2_%da%a9%d8%a7%d8%b1%d8%a8%d8%b1_%d8%af%d8%b1_bash_script\"><\/span>\u06af\u0631\u0641\u062a\u0646 \u0648\u0631\u0648\u062f\u06cc \u0627\u0632 \u06a9\u0627\u0631\u0628\u0631 \u062f\u0631 Bash Script<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u062f\u0633\u062a\u0648\u0631 read \u0628\u0631\u0627\u06cc \u06af\u0631\u0641\u062a\u0646 \u0648\u0631\u0648\u062f\u06cc \u0627\u0632 \u06a9\u0627\u0631\u0628\u0631 \u062f\u0631 bash \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0627\u0633\u0645 user_input.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0631\u0627\u06cc \u06af\u0631\u0641\u062a\u0646 \u0648\u0631\u0648\u062f\u06cc \u0627\u0632 \u06a9\u0627\u0631\u0628\u0631 \u0628\u0647 \u0622\u0646 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f \u060c \u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u06cc\u06a9 \u0631\u0634\u062a\u0647 \u0627\u0632 \u06a9\u0627\u0631\u0628\u0631 \u06af\u0631\u0641\u062a\u0647 \u0645\u06cc \u0634\u0648\u062f \u0648 \u0645\u0642\u062f\u0627\u0631 \u0622\u0646 \u0628\u0627 \u062a\u0631\u06a9\u06cc\u0628 \u0622\u0646 \u0628\u0627 \u0631\u0634\u062a\u0647 \u0647\u0627\u06cc \u062f\u06cc\u06af\u0631 \u0646\u0645\u0627\u06cc\u0634 \u0645\u06cc\u062f\u0647\u062f.<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\necho \"Enter Your Name\"\r\nread name\r\necho \"Welcome $name to Rasanegar\"<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 \u0632\u06cc\u0631 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<div>\n<div id=\"wpbody\">\n<div>\n<pre class=\"\">$ bash user_input.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h8.png\" sizes=\"(max-width: 732px) 100vw, 732px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h8.png 732w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h8-300x45.png 300w\" alt=\"\" width=\"732\" height=\"111\" title=\"\"><\/p>\n<p>\u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0632 \u0637\u0631\u06cc\u0642 \u0644\u06cc\u0646\u06a9 \u0632\u06cc\u0631 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\u06cc \u062f\u0631 \u062e\u0635\u0648\u0635 \u062f\u0633\u062a\u0648\u0631 read \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0646\u06cc\u062f<\/p>\n<p dir=\"ltr\"><a href=\"https:\/\/linuxhint.com\/bash-script-user-input\/\" class=\"broken_link\" target=\"_blank\" rel=\"noopener\">https:\/\/linuxhint.com\/bash-script-user-input\/<\/a><\/p>\n<p><a href=\".#TOP\" class=\"broken_link\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%b4%d8%b1%d8%b7_if_%d8%af%d8%b1_bash_script\"><\/span>\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0634\u0631\u0637 if \u062f\u0631 Bash Script<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0634\u0645\u0627 \u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0632 \u0634\u0631\u0637 if \u062f\u0631 \u06cc\u06a9 \u06cc\u0627 \u0686\u0646\u062f \u0634\u0631\u0637 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f \u060c \u0634\u0631\u0648\u0639 \u0634\u0631\u0637 \u0628\u0627 if \u0648 \u067e\u0627\u06cc\u0627\u0646 \u0622\u0646 \u0628\u0627 fi \u0645\u06cc \u0628\u0627\u0634\u062f \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0627\u0633\u0645 simple_if.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0631\u0627\u06cc \u0634\u0646\u0627\u062e\u062a \u0639\u0645\u0644\u06a9\u0631\u062f if \u062f\u0631 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0646\u0648\u06cc\u0633\u06cc \u0628\u0634 \u0642\u0631\u0627\u0631 \u062f\u0647\u06cc\u062f \u060c \u062a\u0639\u0631\u06cc\u0641 \u0634\u0631\u0637 \u0632\u06cc\u0631 10 \u0631\u0627 \u0628\u0647 \u06cc\u06a9 \u0645\u062a\u063a\u06cc\u0631 \u0628\u0647 \u0627\u0633\u0645 n \u062a\u062e\u0635\u06cc\u0635 \u0645\u06cc\u062f\u0647\u062f \u0648 \u0627\u06af\u0631 \u0645\u0642\u062f\u0627\u0631 $n \u06a9\u0645\u062a\u0631 \u0627\u0632 1- \u0628\u0627\u0634\u062f \u0627\u0639\u0644\u0627\u0645 \u0645\u06cc\u06a9\u0646\u062f \u06a9\u0647 \u0627\u06cc\u0646 \u06cc\u06a9 \u0639\u062f\u062f 1 \u0631\u0642\u0645\u06cc \u0627\u0633\u062a \u060c \u062f\u0631 \u063a\u06cc\u0631 \u0627\u06cc\u0646 \u0635\u0648\u0631\u062a \u062e\u0631\u0648\u062c\u06cc \u0622\u0646 \u0627\u06cc\u0646 \u062e\u0648\u0627\u0647\u062f \u0628\u0648\u062f \u06a9\u0647 \u0627\u06cc\u0646 \u06cc\u06a9 \u0639\u062f\u062f 2 \u0631\u0642\u0645\u06cc \u0627\u0633\u062a \u060c \u0628\u0631\u0627\u06cc \u0645\u0642\u0627\u06cc\u0633\u0647 \u0627\u0632 -lt \u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a \u060c \u0647\u0645\u0686\u0646\u06cc\u0646 \u0645\u06cc\u200e\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0632 <strong>-eq<\/strong> \u0628\u0631 \u0627\u06cc &#8220;<strong>\u0628\u0631\u0627\u0628\u0631 \u0627\u0633\u062a \u0628\u0627<\/strong>&#8221; \u0648 \u0627\u0632 <strong>-ne<\/strong> \u0628\u0631\u0627\u06cc <strong>\u0646\u0627 \u0628\u0631\u0627\u0628\u0631 \u0627\u0633\u062a<\/strong> \u0628\u0627 \u0648 \u0627\u0632 \u00a0 <strong>-gt<\/strong> \u0628\u0631\u0627\u06cc &#8220;<strong>\u0628\u0632\u0631\u06af\u062a\u0631 \u0627\u0632<\/strong> &#8221; \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\nn=10\r\nif [ $n -lt 10 ];\r\nthen\r\necho \"It is a one digit number\"\r\nelse\r\necho \"It is a two digit number\"\r\nfi<\/pre>\n<\/div>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 \u0632\u06cc\u0631 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<div>\n<pre class=\"\">$ bash simple_if.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h9.png\" sizes=\"(max-width: 730px) 100vw, 730px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h9.png 730w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h9-300x28.png 300w\" alt=\"\" width=\"730\" height=\"68\" title=\"\"><\/p>\n<p><a href=\".#TOP\" class=\"broken_link\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%aa%d8%b9%d8%b1%db%8c%d9%81_if_%d9%88_%d9%85%d9%86%d8%b7%d9%82_and_%d8%af%d8%b1_bash_scripting\"><\/span>\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u0639\u0631\u06cc\u0641 IF \u0648 \u0645\u0646\u0637\u0642 AND \u062f\u0631 Bash Scripting<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0627\u0646\u0648\u0627\u0639 \u0645\u062e\u062a\u0644\u0641 \u0634\u0631\u0637\u0647\u0627\u06cc \u0645\u0646\u0637\u0642\u06cc \u0645\u06cc\u200e\u062a\u0648\u0627\u0646\u062f \u0628\u0627 \u062a\u0639\u0631\u06cc\u0641 \u0634\u0631\u0637 if \u0628\u0627 1 \u0648 \u0686\u0646\u062f \u0634\u0631\u0637 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0634\u0648\u062f \u060c \u0627\u06cc\u0646\u06a9\u0647 \u0686\u0637\u0648\u0631 \u0686\u0646\u062f \u062d\u0627\u0644\u062a \u0645\u062d\u0646\u0644\u0641 \u0628\u0647 \u0647\u0645\u0631\u0627\u0647 \u0645\u0646\u0637\u0642 AND \u0631\u0627 \u062a\u0639\u0631\u06cc\u0641 \u06a9\u0646\u06cc\u062f \u062f\u0631\u00a0 \u0646\u0645\u0648\u0646\u0647 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0622\u0648\u0631\u062f\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a. &#8221; &amp;&amp; &#8221; \u0628\u0631\u0627\u06cc \u0627\u0639\u0645\u0627\u0644 \u0645\u0646\u0637\u0642 AND \u062f\u0631 \u062a\u0639\u0631\u06cc\u0641 IF \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0646\u0627\u0645 if_with_AND.sh \u0628\u0631\u0627\u06cc \u0628\u0631\u0631\u0633\u06cc \u062e\u0631\u0648\u062c\u06cc \u06a9\u062f \u0632\u06cc\u0631 \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u060c \u062f\u0631 \u0627\u06cc\u0646 \u0646\u0645\u0648\u0646\u0647 \u06a9\u062f \u060c \u0645\u0642\u0627\u062f\u06cc\u0631 \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc\u00a0 username \u0648 password\u00a0 \u0627\u0632 \u0648\u0631\u0648\u062f\u06cc \u06a9\u0627\u0631\u0628\u0631 \u06af\u0631\u0641\u062a\u0647 \u0645\u06cc \u0634\u0648\u062f \u0648 \u0628\u0627 \u0645\u0642\u062f\u0627\u0631 admin \u0648 \u0645\u0642\u062f\u0627\u0631 secret \u0645\u0642\u0627\u06cc\u0633\u0647 \u0645\u06cc \u0634\u0648\u062f \u060c \u0627\u06af\u0631 \u0647\u0631 \u062f\u0648 \u06cc\u06a9\u06cc \u0628\u0627\u0634\u0646\u062f \u062e\u0631\u0648\u062c\u06cc valid user \u0646\u0645\u0627\u06cc\u0634 \u062f\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f \u062f\u0631 \u063a\u06cc\u0631 \u0627\u06cc\u0646 \u0635\u0648\u0631\u062a invalid user \u0646\u0645\u0627\u06cc\u0634 \u062f\u0627\u0647\u062f \u0645\u06cc \u0634\u0648\u062f<\/p>\n<div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sh\" data-enlighter-title=\"\">!\/bin\/bash\r\n\r\necho &quot;Enter username&quot;\r\nread username\r\necho &quot;Enter password&quot;\r\nread password\r\n\r\nif [[ ( $username == &quot;admin&quot; &amp;&amp; $password == &quot;secret&quot; ) ]]; then\r\necho &quot;valid user&quot;\r\nelse\r\necho &quot;invalid user&quot;\r\nfi<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n<p><\/main><\/p>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 \u0632\u06cc\u0631 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<p><main id=\"main\"><\/p>\n<article id=\"post-28307\">\n<div>\n<div id=\"wpbody\">\n<div>\n<pre class=\"\">$ bash if_with_AND.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h10.png\" sizes=\"(max-width: 729px) 100vw, 729px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h10.png 729w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h10-300x101.png 300w\" alt=\"\" width=\"729\" height=\"245\" title=\"\"><\/p>\n<p><a href=\".#TOP\" class=\"broken_link\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%aa%d8%b9%d8%b1%db%8c%d9%81_if_%d9%88_%d9%85%d9%86%d8%b7%d9%82_or_%d8%af%d8%b1_bash_scripting\"><\/span>\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u0639\u0631\u06cc\u0641 IF \u0648 \u0645\u0646\u0637\u0642 OR \u062f\u0631 Bash Scripting<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>&#8221; || &#8221; \u0628\u0631\u0627\u06cc \u062a\u0639\u0631\u06cc\u0641 \u0645\u0646\u0637\u0642 OR \u062f\u0631 \u0634\u0631\u0637 if \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0627\u0633\u0645 if_wiht_OR.sh \u0627\u06cc\u062c\u0627\u062f \u0648 \u06a9\u062f \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0622\u0646 \u06a9\u067e\u06cc \u06a9\u0646\u06cc\u062f \u060c \u0645\u0642\u062f\u0627\u0631 n \u0627\u0632 \u0648\u0631\u0648\u062f\u06cc \u06a9\u0627\u0631\u0628\u0631 \u06af\u0631\u0641\u062a\u0647 \u0645\u06cc \u0634\u0648\u062f \u060c \u0627\u06af\u0631 \u0645\u0642\u062f\u0627\u0631 \u0628\u0631\u0627\u0628\u0631 \u0628\u0627 15 \u06cc\u0627 45 \u0628\u0627\u0634\u062f \u0628\u0627\u0634\u062f \u062e\u0631\u0648\u062c\u06cc \u0628\u0631\u0627\u0628\u0631 \u0628\u0627 \u201cYou won the game\u201d,\u062f\u0631 \u063a\u06cc\u0631 \u0627\u06cc\u0646 \u0635\u0648\u0631\u062a You lost the game \u0646\u0645\u0627\u06cc\u0634 \u062f\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\n\r\necho \"Enter any number\"\r\nread n\r\n\r\nif [[ ( $n -eq 15 || $n -eq 45 ) ]]\r\nthen\r\necho \"You won the game\"\r\nelse\r\necho \"You lost the game\"\r\nfi<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n<p><\/main><\/p>\n<p>\u0628\u0627 \u062f\u0633\u062a\u0648\u0631 \u0632\u06cc\u0631 \u0622\u0646 \u0631\u0627 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<p><main id=\"main\"><\/p>\n<article id=\"post-28307\">\n<div>\n<div id=\"wpbody\">\n<div>\n<pre class=\"\">$ bash if_with_OR.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h11.png\" sizes=\"(max-width: 730px) 100vw, 730px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h11.png 730w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h11-300x71.png 300w\" alt=\"\" width=\"730\" height=\"173\" title=\"\"><\/p>\n<p><a href=\".#TOP\" class=\"broken_link\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%aa%d8%b9%d8%b1%db%8c%d9%81_%d8%b4%d8%b1%d8%b7_if_%d8%af%d8%b1_shell_scripting\"><\/span>\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u0639\u0631\u06cc\u0641 \u0634\u0631\u0637 IF \u062f\u0631 Shell Scripting<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>&nbsp;<\/p>\n<p>The use of else if condition is little different in bash than other programming language. \u2018elif\u2019 is used to define else if condition in bash. Create a file named, \u2018elseif_example.sh\u2019 and add the following script to check how else if is defined in bash script.<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\n\r\necho \"Enter your lucky number\"\r\nread n\r\n\r\nif [ $n -eq 101 ];\r\nthen\r\necho \"You got 1st prize\"\r\nelif [ $n -eq 510 ];\r\nthen\r\necho \"You got 2nd prize\"\r\nelif [ $n -eq 999 ];\r\nthen\r\necho \"You got 3rd prize\"\r\n\r\nelse\r\necho \"Sorry, try for the next time\"\r\nfi<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n<p><\/main><\/p>\n<p>\u0628\u0627 \u062f\u0633\u062a\u0648\u0631 \u0632\u06cc\u0631 \u0622\u0646 \u0631\u0627 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<p><main id=\"main\"><\/p>\n<article id=\"post-28307\">\n<div>\n<div id=\"wpbody\">\n<div>\n<pre class=\"\">$ bash elseif_example.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h12.png\" sizes=\"(max-width: 729px) 100vw, 729px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h12.png 729w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h12-300x99.png 300w\" alt=\"\" width=\"729\" height=\"241\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d8%aa%d8%b9%d8%b1%db%8c%d9%81_case\"><\/span>\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u0639\u0631\u06cc\u0641 Case<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0634\u0631\u0637 case \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u0645\u0639\u0627\u062f\u0644 \u0634\u0631\u0637 if-elseif-else \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f \u060c \u0628\u0631\u0627\u06cc \u0634\u0631\u0648\u0639 \u0648 \u067e\u0627\u06cc\u0627\u0646 \u0628\u0644\u0648\u06a9 \u0627\u06cc\u0646 \u0634\u0631\u0637 \u0627\u0632 case \u0648 esac \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u06a9\u0646\u06cc\u0645 \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u062c\u062f\u06cc\u062f \u0628\u0647 \u0646\u0627\u0645 case_example.sh\u00a0 \u0627\u06cc\u062c\u0627\u062f \u0645\u06cc \u06a9\u0646\u06cc\u0645 \u0648 \u0645\u062a\u0646 \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0622\u0646 \u0642\u0631\u0627\u0631 \u0645\u06cc\u200f\u200e\u062f\u0647\u06cc\u0645 \u060c \u062e\u0631\u0648\u062c\u06cc \u06a9\u062f \u0632\u06cc\u0631 \u0645\u0627\u0646\u0646\u062f \u062f\u0633\u062a\u0648\u0631 \u0642\u0628\u0644\u06cc \u062e\u0648\u0627\u0647\u062f \u0628\u0648\u062f .<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\n\r\necho \"Enter your lucky number\"\r\nread n\r\ncase $n in\r\n101)\r\necho echo \"You got 1st prize\" ;;\r\n510)\r\necho \"You got 2nd prize\" ;;\r\n999)\r\necho \"You got 3rd prize\" ;;\r\n*)\r\necho \"Sorry, try for the next time\" ;;\r\nesac<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n<p><\/main><\/p>\n<p>\u0628\u0627 \u062f\u0633\u062a\u0648\u0631 \u0632\u06cc\u0631 \u0622\u0646 \u0631\u0627 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<p><main id=\"main\"><\/p>\n<article id=\"post-28307\">\n<div>\n<div id=\"wpbody\">\n<div>\n<pre class=\"\">$ bash case_example.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h13.png\" sizes=\"(max-width: 725px) 100vw, 725px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h13.png 725w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h13-300x132.png 300w\" alt=\"\" width=\"725\" height=\"318\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%da%af%d8%b1%d9%81%d8%aa%d9%86_%d8%a2%d8%b1%da%af%d9%88%d9%85%d8%a7%d9%86_%d8%a7%d8%b2_%d8%ae%d8%b7_%d9%81%d8%b1%d9%85%d8%a7%d9%86\"><\/span>\u06af\u0631\u0641\u062a\u0646 \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0627\u0632 \u062e\u0637 \u0641\u0631\u0645\u0627\u0646<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0628\u0634 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0645\u06cc\u062a\u0648\u0627\u0646\u062f \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0647\u0627 \u0631\u0627 \u0645\u0627\u0646\u0646\u062f \u062f\u06cc\u06af\u0631 \u0632\u06cc\u0627\u0646 \u0647\u0627\u06cc \u0628\u0631\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc \u0627\u0632 \u062e\u0637 \u0641\u0631\u0645\u0627\u0646 \u0628\u062e\u0648\u0627\u0646\u062f \u060c \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u0645\u062b\u0627\u0644 $1 \u0648 $2 \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc\u06cc \u0647\u0633\u062a\u0646\u062f \u06a9\u0647 \u0628\u0631\u0627\u06cc \u06af\u0631\u0641\u062a\u0646 \u0648\u0631\u0648\u062f\u06cc \u062e\u0637\u0647\u0627\u06cc \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0627\u0648\u0644\u06cc \u0648 \u062f\u0648\u0645\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u06a9\u0646\u06cc\u0645 \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0627 \u0646\u0627\u0645 command_line.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0622\u0646 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f \u060c \u062f\u0648 \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u062a\u0648\u0633\u0637 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u062e\u0648\u0627\u0646\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f \u0648 \u0645\u062c\u0645\u0648\u0639 \u0627\u0639\u062f\u0627\u062f \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0631\u0627 \u062f\u0631 \u062e\u0631\u0648\u062c\u06cc \u0646\u0645\u0627\u06cc\u0634 \u0645\u06cc\u062f\u0647\u062f<\/p>\n<p>Bash script can read input from command line argument like other programming language. For example, $1 and $2 variable are used to read first and second command line arguments. Create a file named \u201ccommand_line.sh\u201d and add the following script. Two argument values read by the following script and prints the total number of arguments and the argument values as output.<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\necho \"Total arguments : $#\"\r\necho \"1st Argument = $1\"\r\necho \"2nd argument = $2\"<\/pre>\n<\/div>\n<p>\u0628\u0627 \u062f\u0633\u062a\u0648\u0631 \u0632\u06cc\u0631 \u0622\u0646 \u0631\u0627 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<div>\n<pre class=\"\">$ bash command_line.sh <a href=\"https:\/\/rasanegaar.com\/blog\/linux-kernel-4x-vulnerability-cve-2019-8912\/\">Linux<\/a> Hint<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h14.png\" sizes=\"(max-width: 731px) 100vw, 731px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h14.png 731w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h14-300x39.png 300w\" alt=\"\" width=\"731\" height=\"96\" title=\"\"><\/p>\n<p>\u0645\u06cc\u200e\u062a\u0648\u0627\u0646\u06cc\u062f \u062f\u0631 \u0644\u06cc\u0646\u06a9 \u0632\u06cc\u0631 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\u06cc \u062f\u0631 \u062e\u0635\u0648\u0635 \u0622\u0631\u0648\u06af\u0645\u0627\u0646 \u0647\u0627 \u062f\u0631 \u0628\u0634 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a\u06cc\u0646\u06af \u0628\u062f\u0633\u062a \u0628\u06cc\u0627\u0648\u0631\u06cc\u062f<\/p>\n<p dir=\"ltr\"><a href=\"https:\/\/linuxhint.com\/command_line_arguments_bash_script\/\" target=\"_blank\" rel=\"noopener\">https:\/\/linuxhint.com\/command_line_arguments_bash_script\/<\/a><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%da%af%d8%b1%d9%81%d8%aa%d9%86_%d8%a2%d8%b1%da%af%d9%88%d9%85%d8%a7%d9%86_%d8%a7%d8%b2_%d8%ae%d8%b7_%d9%81%d8%b1%d9%85%d8%a7%d9%86_%d8%a8%d8%a7_%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87_%d8%a7%d8%b2_%d9%86%d8%a7%d9%85_%d9%87%d8%a7\"><\/span>\u06af\u0631\u0641\u062a\u0646 \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0627\u0632 \u062e\u0637 \u0641\u0631\u0645\u0627\u0646 \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0646\u0627\u0645 \u0647\u0627<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0645\u06cc\u062e\u0648\u0627\u0647\u06cc\u062f \u0628\u062f\u0627\u0646\u06cc\u062f \u062c\u0637\u0648\u0631 \u0645\u06cc\u200e\u062a\u0648\u0627\u0646\u06cc\u062f \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0647\u0627\u06cc \u062e\u0637 \u0641\u0631\u0645\u0627\u0646 \u0631\u0627 \u0628\u0647 \u0647\u0645\u0631\u0627\u0647 \u0646\u0627\u0645 \u0622\u0646\u0647\u0627 \u0628\u062e\u0648\u0627\u0646\u06cc\u062f \u060c \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0631\u0627 \u0628\u0631\u0627\u06cc \u0634\u0645\u0627 \u0627\u0646\u062c\u0627\u0645 \u0645\u06cc\u062f\u0647\u062f \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0627\u0633\u0645 command_line_names.sh \u0627\u06cc\u062c\u0627\u062f \u0648 \u06a9\u0646\u06cc\u062f \u0648 \u06a9\u062f \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0622\u0646 \u0642\u0631\u0627\u0631 \u062f\u0647\u06cc\u062f \u060c\u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u062f\u0648 \u0622\u0631\u06af\u0648\u0645\u0627\u0646 X \u0648 Y \u062a\u0648\u0633\u0637 \u0627\u06cc\u0646 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u062e\u0648\u0627\u0646\u062f\u0647\u0645\u06cc \u0634\u0648\u062f \u0648 \u0648 \u0645\u062c\u0645\u0648\u0639 X , Y \u0631\u0648\u06cc \u0635\u0641\u062d\u0647 \u067e\u0631\u06cc\u0646\u062a \u0645\u06cc\u200e\u0634\u0648\u062f<\/p>\n<div>\n<pre>#!\/bin\/bash\r\nfor arg in \"$@\"\r\ndo\r\nindex=$(echo $arg | cut -f1 -d=)\r\nval=$(echo $arg | cut -f2 -d=)\r\ncase $index in\r\nX) x=$val;;\r\n\r\nY) y=$val;;\r\n\r\n*)\r\nesac\r\ndone\r\n((result=x+y))\r\necho \"X+Y=$result\"<\/pre>\n<\/div>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 bash \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f \u0648 \u062f\u0648 \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0631\u0627 \u062f\u0631 \u062e\u0637 \u0641\u0631\u0645\u0627\u0646 \u0628\u0647 \u0622\u0646 \u067e\u0627\u0633 \u0628\u062f\u0647\u06cc\u062f<\/p>\n<div>\n<pre class=\"\">$ bash command_line_names X=45 Y=30<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h15.png\" sizes=\"(max-width: 732px) 100vw, 732px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h15.png 732w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h15-300x30.png 300w\" alt=\"\" width=\"732\" height=\"72\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%aa%d8%b1%da%a9%db%8c%d8%a8_%d9%85%d8%aa%d8%ba%db%8c%d8%b1%d9%87%d8%a7%db%8c_%d8%b1%d8%b4%d8%aa%d9%87%e2%80%8e%d8%a7%db%8c\"><\/span>\u062a\u0631\u06a9\u06cc\u0628 \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc \u0631\u0634\u062a\u0647\u200e\u0627\u06cc<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0634\u0645\u0627 \u0628\u0647 \u0633\u0627\u062f\u06af\u06cc \u0645\u06cc\u200e\u062a\u0648\u0627\u0646\u06cc\u062f \u062f\u0648 \u0631\u0634\u062a\u0647 \u0631\u0627 \u06a9\u0647 \u062f\u0631 \u0645\u062a\u06cc\u063a\u0631 \u0630\u062e\u06cc\u0631\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a \u0631\u0627 \u062f\u0631 Bash \u0627\u062f\u063a\u0627\u0645 \u06a9\u0646\u06cc\u062f \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0627\u0633\u0645 string -combine.sh \u0628\u0633\u06cc\u0627\u0632\u06cc\u062f \u0648 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0622\u0646 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f \u060c \u062f\u0631 \u06a9\u062f \u0632\u06cc\u0631 \u0645\u06cc\u200e\u0628\u06cc\u0646\u06cc\u062f \u06a9\u0647 \u0686\u0637\u0648\u0631 \u062f\u0648 \u0631\u0634\u062a\u0647 \u0628\u0627 \u0642\u0631\u0627\u0631 \u062f\u0627\u062f\u0646 \u062f\u0648 \u0645\u062a\u063a\u06cc\u0631 \u06a9\u0646\u0627\u0631 \u0647\u0645 \u0628\u0627 \u0627\u067e\u0631\u0627\u062a\u0648\u0631 + \u0628\u0627 \u0647\u0645 \u0627\u062f\u063a\u0627\u0645 \u0645\u06cc\u200e\u0634\u0648\u0646\u062f<\/p>\n<div>\n<pre>\r\n\r\n#!\/bin\/bash\r\n\r\nstring1=\"Linux\"\r\nstring2=\"Hint\"\r\necho \"$string1$string2\"\r\nstring3=$string1+$string2\r\nstring3+=\" is a good tutorial blog site\"\r\necho $string3<\/pre>\n<\/div>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 bash \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f <\/p>\n<div>\n<pre class=\"\">$ bash string_combine.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h16.png\" sizes=\"(max-width: 731px) 100vw, 731px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h16.png 731w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h16-300x36.png 300w\" alt=\"\" width=\"731\" height=\"87\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%af%d8%b1%db%8c%d8%a7%d9%81%d8%aa_%d8%b2%db%8c%d8%b1%d8%b1%d8%b4%d8%aa%d9%87_%d8%a7%d8%b2_%db%8c%da%a9_%d8%b1%d8%b4%d8%aa%d9%87\"><\/span>\u062f\u0631\u06cc\u0627\u0641\u062a \u0632\u06cc\u0631\u0631\u0634\u062a\u0647 \u0627\u0632 \u06cc\u06a9 \u0631\u0634\u062a\u0647:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0645\u0627\u0646\u0646\u062f \u062f\u06cc\u06af\u0631 \u0632\u06cc\u0627\u0646 \u0647\u0627 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc \u060c \u0628\u0634 \u0647\u0645 \u0647\u06cc\u0686 \u062a\u0627\u0628\u0639 \u062f\u0627\u062e\u0644\u06cc \u0628\u0631\u0627\u06cc \u062c\u062f\u0627\u06a9\u0631\u062f\u0646 \u0645\u0642\u062f\u0627\u0631 \u0627\u0632 \u062f\u0627\u062f\u0647 \u0631\u0634\u062a\u0647 \u0646\u062f\u0627\u0631\u062f \u060c \u0627\u0645\u0627 \u0634\u0645\u0627 \u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u0639\u0645\u0644\u06a9\u0631\u062f substring \u0631\u0627 \u0628\u0627 \u0631\u0648\u0634 \u062f\u06cc\u06af\u0631\u06cc \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u062f \u060c \u0627\u06cc\u0646 \u0631\u0648\u0634 \u062f\u0631 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0646\u0645\u0627\u06cc\u0634 \u062f\u0627\u062f\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a \u060c \u0628\u0631\u0627\u06cc \u062a\u0633\u062a \u0627\u06cc\u0646 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0627\u0633\u0646 substring_example.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u0645\u062f \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0622\u0646 \u0642\u0631\u0627\u0631 \u062f\u0647\u06cc\u062f \u060c \u062f\u0631 \u06a9\u062f \u0632\u06cc\u0631 6 \u0646\u0634\u0627\u0646 \u06af\u0631 \u0646\u0642\u0637\u0647 \u0634\u0631\u0648\u0639 \u062c\u0627\u06cc\u06cc \u0627\u0633\u062a \u06a9\u0647 substring \u0622\u063a\u0627\u0632 \u0645\u06cc \u0634\u0648\u062f \u0648 5 \u0646\u0634\u0627\u0646\u06af\u0631 \u0637\u0648\u0644 \u0622\u0646 \u0632\u06cc\u0631 \u0631\u0634\u062a\u0647 \u0627\u0633\u062a.<\/p>\n<div>\n<pre>#!\/bin\/bash\r\nStr=\"Learn Linux from LinuxHint\"\r\nsubStr=${Str:6:5}\r\necho $subStr<\/pre>\n<\/div>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 bash \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<div>\n<pre class=\"\">$ bash substring_example.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h17.png\" sizes=\"(max-width: 731px) 100vw, 731px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h17.png 731w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h17-300x28.png 300w\" alt=\"\" width=\"731\" height=\"69\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%ac%d9%85%d8%b9_%d8%af%d9%88_%d8%b9%d8%af%d8%af\"><\/span>\u062c\u0645\u0639 \u062f\u0648 \u0639\u062f\u062f:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0634\u0645\u0627 \u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u0639\u0645\u0644\u06cc\u0627\u062a \u062d\u0633\u0627\u0628\u06cc \u0631\u0627 \u062f\u0631 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0646\u0648\u06cc\u0633\u06cc bash \u0628\u0647 \u0686\u0646\u062f \u0631\u0648\u0634 \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u062f \u060c \u0627\u06cc\u0646\u06a9\u0647 \u0686\u0637\u0648\u0631 \u0645\u06cc\u200e\u062a\u0648\u0627\u0646\u06cc\u062f \u062f\u0648 \u0639\u062f\u062f \u0635\u062d\u06cc\u062d \u0631\u0627 \u062f\u0631 \u062f\u0631 \u0628\u0634 \u0628\u0627 \u062f\u0648 \u067e\u0631\u0627\u0646\u062a\u0632 (()) \u062c\u0645\u0639 \u06a9\u0646\u06cc\u062f \u062f\u0631 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0646\u0645\u0627\u06cc\u0634 \u062f\u0627\u062f\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0627\u0633\u0645 add_numbers.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u06a9\u062f \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0622\u0646 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f \u060c \u062f\u0648 \u0639\u062f\u062f \u0635\u062d\u06cc\u062d \u0627\u0632 \u06a9\u0627\u0631\u0628\u0631 \u06af\u0631\u0641\u062a\u0647 \u0645\u06cc\u200e\u0634\u0648\u062f \u0648 \u0646\u062a\u06cc\u062c\u0647 \u062c\u0645\u0639 \u0646\u0634\u0627\u0646 \u062f\u0627\u062f\u0647 \u0645\u06cc\u200e\u0634\u0648\u062f.<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\necho \"Enter first number\"\r\nread x\r\necho \"Enter second number\"\r\nread y\r\n(( sum=x+y ))\r\necho \"The result of addition=$sum\"<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n<p><\/main><\/p>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 bash \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<p><main id=\"main\"><\/p>\n<article id=\"post-28307\">\n<div>\n<div id=\"wpbody\">\n<div>\n<pre class=\"\">$ bash add_numbers.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h18.png\" sizes=\"(max-width: 733px) 100vw, 733px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h18.png 733w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h18-300x56.png 300w\" alt=\"\" width=\"733\" height=\"137\" title=\"\"><\/p>\n<p>\u062f\u0631 \u0644\u06cc\u0646\u06a9 \u0632\u06cc\u0631 \u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u062f\u0631 \u062e\u0635\u0648\u0635 \u0639\u0645\u0644\u06cc\u0627\u062a \u062d\u0633\u0627\u0628\u06cc \u0648 \u0639\u0645\u0644\u06af\u0631\u0647\u0627\u06cc \u0622\u0646 \u062f\u0631 \u0628\u0634 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0628\u06cc\u0634\u062a\u0631 \u0622\u0634\u0646\u0627 \u0634\u0648\u06cc\u062f <\/p>\n<p><a href=\"https:\/\/linuxhint.com\/bash_arithmetic_operations\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https:\/\/linuxhint.com\/bash_arithmetic_operations\/<\/a><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%a7%db%8c%d8%ac%d8%a7%d8%af_%d8%aa%d8%a7%d8%a8%d8%b9\"><\/span>\u0627\u06cc\u062c\u0627\u062f \u062a\u0627\u0628\u0639<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u062f\u0631 \u06a9\u062f \u0646\u0645\u0648\u0646\u0647 \u0632\u06cc\u0631 \u06cc\u06a9 \u062a\u0627\u0628\u0639 \u0633\u0627\u062f\u0647 \u0627\u06cc\u062c\u0627\u062f \u0648 \u0622\u0646\u0631 \u0627 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0645\u06cc\u200e\u06a9\u0646\u06cc\u0645 \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0627\u0633\u0645 sunction_example.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u06a9\u062f \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0622\u0646 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f \u060c \u0634\u0645\u0627 \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u062a\u0627\u0628\u0639 \u0631\u0627 \u0628\u062f\u0648\u0646 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u067e\u0631\u0627\u0646\u062a\u0631 \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0627\u0633\u0645 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u06a9\u0646\u06cc\u062f \u200e<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\nfunction F1()\r\n{\r\necho 'I like bash programming'\r\n}\r\n\r\nF1<\/pre>\n<\/div>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 bash \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<div>\n<pre class=\"\">$ bash function_example.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h19.png\" sizes=\"(max-width: 733px) 100vw, 733px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h19.png 733w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h19-300x29.png 300w\" alt=\"\" width=\"733\" height=\"70\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%a7%db%8c%d8%ac%d8%a7%d8%af_%d8%aa%d8%a7%d8%a8%d8%b9_%d8%a8%d8%a7_%d9%be%d8%a7%d8%b1%d8%a7%d9%85%d8%aa%d8%b1%d9%87%d8%a7\"><\/span>\u0627\u06cc\u062c\u0627\u062f \u062a\u0627\u0628\u0639 \u0628\u0627 \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u062f\u0631 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0628\u064e\u0634 \u0646\u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627\u06cc \u062a\u0627\u0628\u0639 \u06cc\u0627 \u0622\u0631\u06af\u0648\u0645\u0627\u0646 \u0647\u0627 \u0631\u0627 \u062f\u0631 \u0632\u0645\u0627\u0646 \u062a\u0639\u0631\u06cc\u0641 \u062a\u0627\u0628\u0639 \u0628\u0634\u0646\u0627\u0633\u0627\u0646\u06cc\u062f \u060c \u0627\u0645\u0627 \u0645\u06cc\u200e\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0632 \u067e\u0627\u0631\u0645\u062a\u0631\u0647\u0627 \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc \u062f\u06cc\u06af\u0631 \u062f\u0631 \u062a\u0627\u0628\u0639 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f \u060c \u0627\u06af\u0631 \u062f\u0648 \u0645\u0642\u062f\u0627\u0631 \u062f\u0632 \u0632\u0645\u0627\u0646 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u062a\u0627\u0628\u0639 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0634\u0648\u062f \u060c \u067e\u0633 \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc $1 \u0648 $2 \u0628\u0631\u0627\u06cc \u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u0642\u0627\u062f\u06cc\u0631 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0627\u0633\u0645 function_parameters.sh \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0648 \u06a9\u062f \u0632\u06cc\u0631 \u0631\u0627 \u062f\u0631 \u0622\u0646 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f \u060c \u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u062a\u0627\u0628\u0639 Rectangle_Ara \u0645\u062d\u06cc\u0637 \u06cc\u06a9 \u0645\u0633\u062a\u0637\u06cc\u0644 \u0631\u0627 \u0628\u0631 \u0627\u0633\u0627\u0633 \u0645\u0642\u0627\u062f\u06cc\u0631 \u067e\u0627\u0631\u0627\u0645\u062a\u0631\u0647\u0627 \u0645\u062d\u0627\u0633\u0628\u0647 \u0645\u06cc \u06a9\u0646\u062f<\/p>\n<div>\n<pre class=\"\">#!\/bin\/bash\r\n\r\nRectangle_Area() {\r\narea=$(($1 * $2))\r\necho \"Area is : $area\"\r\n}\r\n\r\nRectangle_Area 10 20<\/pre>\n<\/div>\n<p>\u0641\u0627\u06cc\u0644 \u0631\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 bash \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/p>\n<div>\n<pre class=\"\">$ bash function_parameter.sh<\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h20.png\" sizes=\"(max-width: 735px) 100vw, 735px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h20.png 735w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h20-300x29.png 300w\" alt=\"\" width=\"735\" height=\"72\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%d8%a7%d8%b1%d8%ac%d8%a7%d8%b9_return_value_%d8%af%d8%b1_funtion\"><\/span>\u0627\u0631\u062c\u0627\u0639 Return Value \u062f\u0631 Funtion <span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u0641\u0627\u0646\u06a9\u0634\u0646\u0647\u0627\u06cc \u0628\u0634 \u0645\u06cc\u062a\u0648\u0627\u0646\u0646\u062f \u0645\u0642\u0627\u062f\u06cc\u0631 \u0639\u062f\u062f\u06cc \u0648 \u0631\u0634\u062a\u0647 \u0627\u06cc \u0631\u0627 \u067e\u0627\u0633 \u0628\u062f\u0647\u0646\u062f \u060c \u062f\u0631 \u0645\u062b\u0644 \u0632\u06cc\u0631 \u0627\u06cc\u0646\u06a9\u0647 \u0686\u0637\u0648\u0631 \u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u06cc\u06a9 \u0645\u0642\u062f\u0627\u0631 \u0631\u0634\u062a\u0647 \u0627\u06cc \u0631\u0627 \u0627\u0632 \u062a\u0627\u0628\u0639 \u067e\u0627\u0633 \u0628\u062f\u0647\u06cc\u062f \u0646\u0645\u0627\u06cc\u0634 \u062f\u0627\u062f\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a \u060c \u06cc\u06a9 \u0641\u0627\u06cc\u0644 \u0628\u0647 \u0627\u0633\u0645 function_return.sh \u0628\u0633\u0627\u0632\u06cc\u062f \u0648 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0622\u0646 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f \u060c \u062a\u0627\u0628\u0639 greeting() \u0645\u0642\u062f\u0627\u0631 \u06cc\u06a9 \u0645\u0642\u062f\u0627\u0631 \u0631\u0634\u062a\u0647 \u0627\u06cc \u0628\u0647 \u0645\u062a\u063a\u06cc\u0631 val \u0628\u0631\u0645\u06cc\u06af\u0631\u062f\u0627\u0646\u062f \u0648 \u0628\u0639\u062f \u062f\u0631 \u062e\u0631\u0648\u062c\u06cc<\/p>\n<p>Bash function can pass both numeric and string values. How you can pass a string value from the function is shown in the following example. Create a file named, \u2018function_return.sh\u2019 and add the following code. The function, greeting() returns a string value into the variable, val which prints later by combining with other string.<\/p>\n<div>\n<div>#!\/bin\/bash<br \/>\nfunction greeting() {<\/p>\n<p>str=&#8221;Hello, $name&#8221;<br \/>\necho $str<\/p>\n<p>}<\/p>\n<p>echo &#8220;Enter your name&#8221;<br \/>\nread name<\/p>\n<p>val=$(greeting)<br \/>\necho &#8220;Return value of the function is $val&#8221;<\/div>\n<\/div>\n<p>Run the file with bash command.<\/p>\n<div>\n<div>$ bash function_return.sh<\/div>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h21.png\" sizes=\"(max-width: 728px) 100vw, 728px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h21.png 728w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h21-300x42.png 300w\" alt=\"\" width=\"728\" height=\"103\" title=\"\"><\/p>\n<p>You can check the following link to know more about the use of bash function.<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/return-string-bash-functions\/\" target=\"_blank\" rel=\"noopener\">https:\/\/linuxhint.com\/return-string-bash-functions\/<\/a><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"make_directory\"><\/span>Make Directory:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Bash uses \u2018mkdir\u2019 command to create a new directory. Create a file named \u2018make_directory.sh\u2019 and add the following code to take a new directory name from the user. If the directory name is not exist in the current location then it will create the directory, otherwise the program will display error.<\/p>\n<div>\n<div>#!\/bin\/bash<br \/>\necho &#8220;Enter directory name&#8221;<br \/>\nread newdir<br \/>\n`mkdir $newdir`<\/div>\n<\/div>\n<p>Run the file with bash command.<\/p>\n<div>\n<div>$ bash make_directory.sh<\/div>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h22.png\" sizes=\"(max-width: 734px) 100vw, 734px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h22.png 734w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h22-300x49.png 300w\" alt=\"\" width=\"734\" height=\"120\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"make_directory_by_checking_existence\"><\/span>Make directory by checking existence:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>If you want to check the existence of directory in the current location before executing the \u2018mkdir\u2019 command then you can use the following code. \u2018-d\u2019 option is used to test a particular directory is exist or not. Create a file named, \u2018directory_exist.sh\u2019 and add the following code to create a directory by checking existence.<\/p>\n<div>\n<div>#!\/bin\/bash<br \/>\necho &#8220;Enter directory name&#8221;<br \/>\nread ndir<br \/>\nif [ -d &#8220;$ndir&#8221; ]<br \/>\nthen<br \/>\necho &#8220;Directory exist&#8221;<br \/>\nelse<br \/>\n`mkdir $ndir`<br \/>\necho &#8220;Directory created&#8221;<br \/>\nfi<\/div>\n<\/div>\n<p>Run the file with bash command.<\/p>\n<div>\n<div>$ bash directory_exist.sh<\/div>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h23.png\" sizes=\"(max-width: 729px) 100vw, 729px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h23.png 729w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h23-300x53.png 300w\" alt=\"\" width=\"729\" height=\"130\" title=\"\"><\/p>\n<p>You can check the following link to know more about directory creation.<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/bash_mkdir_not_existent_path\/\" target=\"_blank\" rel=\"noopener\">https:\/\/linuxhint.com\/bash_mkdir_not_existent_path\/<\/a><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"read_a_file\"><\/span>Read a File:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>You can read any file line by line in bash by using loop. Create a file named, \u2018read_file.sh\u2019 and add the following code to read an existing file named, \u2018book.txt\u2019.<\/p>\n<div>\n<div>#!\/bin\/bash<br \/>\nfile=&#8217;book.txt&#8217;<br \/>\nwhile read line; do<br \/>\necho $line<br \/>\ndone &lt; $file<\/div>\n<\/div>\n<p>Run the file with bash command.<\/p>\n<div>\n<div>$ bash read_file.sh<\/div>\n<\/div>\n<p>Run the following command to check the original content of \u2018book.txt\u2019 file.<\/p>\n<div>\n<div>$ cat book.txt<\/div>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h24.png\" sizes=\"(max-width: 729px) 100vw, 729px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h24.png 729w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h24-300x86.png 300w\" alt=\"\" width=\"729\" height=\"210\" title=\"\"><\/p>\n<p>You can check the following link to know the different ways to read file.<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/read_file_line_by_line_bash\/\" target=\"_blank\" rel=\"noopener\">https:\/\/linuxhint.com\/read_file_line_by_line_bash\/<\/a><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"delete_a_file\"><\/span>Delete a File:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u2018rm\u2019 command is used in bash to remove any file. Create a file named \u2018delete_file.sh\u2019 with the following code to take the filename from the user and remove. Here, \u2018-i\u2019 option is used to get permission from the user before removing the file.<\/p>\n<div>\n<div>#!\/bin\/bash<br \/>\necho &#8220;Enter filename to remove&#8221;<br \/>\nread fn<br \/>\nrm -i $fn<\/div>\n<\/div>\n<p>Run the file with bash command.<\/p>\n<div>\n<div>$ ls<br \/>\n$ bash delete_file.sh<br \/>\n$ ls<\/div>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h25.png\" sizes=\"(max-width: 732px) 100vw, 732px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h25.png 732w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h25-300x76.png 300w\" alt=\"\" width=\"732\" height=\"185\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"append_to_file\"><\/span>Append to File:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>New data can be added into any existing file by using \u2018&gt;&gt;\u2019 operator in bash. Create a file named \u2018append_file.sh\u2019 and add the following code to add new content at the end of the file. Here, \u2018Learning Laravel 5\u2019 will be added at the of \u2018book.txt\u2019 file after executing the script.<\/p>\n<div>\n<div>#!\/bin\/bash<\/p>\n<p>echo &#8220;Before appending the file&#8221;<br \/>\ncat book.txt<\/p>\n<p>echo &#8220;Learning Laravel 5&#8221;&gt;&gt; book.txt<br \/>\necho &#8220;After appending the file&#8221;<br \/>\ncat book.txt<\/div>\n<\/div>\n<p>Run the file with bash command.<\/p>\n<div>\n<div>$ bash append_file.sh<\/div>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h26.png\" sizes=\"(max-width: 728px) 100vw, 728px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h26.png 728w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h26-300x102.png 300w\" alt=\"\" width=\"728\" height=\"247\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"test_if_file_exist\"><\/span>Test if File Exist:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>You can check the existence of file in bash by using \u2018-e\u2019 or \u2018-f\u2019 option. \u2018-f\u2019 option is used in the following script to test the file existence. Create a file named, \u2018file_exist.sh\u2019 and add the following code. Here, the filename will pass from the command line.<\/p>\n<div>\n<div>#!\/bin\/bash<br \/>\nfilename=$1<br \/>\nif [ -f &#8220;$filename&#8221; ]; then<br \/>\necho &#8220;File exists&#8221;<br \/>\nelse<br \/>\necho &#8220;File does not exist&#8221;<br \/>\nfi<\/div>\n<\/div>\n<p>Run the following commands to check the existence of the file. Here, book.txt file exists and book2.txt is not exist in the current location.<\/p>\n<div>\n<div>$ ls<br \/>\n$ bash file_exist.sh book.txt<br \/>\n$ bash file_exist.sh book2.txt<\/div>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h27.png\" sizes=\"(max-width: 725px) 100vw, 725px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h27.png 725w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h27-300x61.png 300w\" alt=\"\" width=\"725\" height=\"148\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"send_email\"><\/span>Send Email:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>You can send email by using \u2018mail\u2019 or \u2018sendmail\u2019 command. Before using these commands, you have to install all necessary packages. Create a file named, \u2018mail_example.sh\u2019 and add the following code to send the email.<\/p>\n<div>\n<div>#!\/bin\/bash<br \/>\nRecipient=\u201dadmin@example.com\u201d<br \/>\nSubject=\u201dGreeting\u201d<br \/>\nMessage=\u201dWelcome to our site\u201d<br \/>\n`mail -s $Subject $Recipient &lt;&lt;&lt; $Message`<\/div>\n<\/div>\n<p>Run the file with bash command.<\/p>\n<div>\n<div>$ bash mail_example.sh<\/div>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h28.png\" sizes=\"(max-width: 733px) 100vw, 733px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h28.png 733w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h28-300x28.png 300w\" alt=\"\" width=\"733\" height=\"69\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"get_parse_current_date\"><\/span>Get Parse Current Date:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>You can get the current system date and time value using `date` command. Every part of date and time value can be parsed using \u2018Y\u2019, \u2018m\u2019, \u2018d\u2019, \u2018H\u2019, \u2018M\u2019 and \u2018S\u2019. Create a new file named \u2018date_parse.sh\u2019 and add the following code to separate day, month, year, hour, minute and second values.<\/p>\n<div>\n<div>#!\/bin\/bash<br \/>\nYear=`date +%Y`<br \/>\nMonth=`date +%m`<br \/>\nDay=`date +%d`<br \/>\nHour=`date +%H`<br \/>\nMinute=`date +%M`<br \/>\nSecond=`date +%S`<br \/>\necho `date`<br \/>\necho &#8220;Current Date is: $Day-$Month-$Year&#8221;<br \/>\necho &#8220;Current Time is: $Hour:$Minute:$Second&#8221;<\/div>\n<\/div>\n<p>Run the file with bash command.<\/p>\n<div>\n<div>$ bash date_parse.sh<\/div>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h29.png\" sizes=\"(max-width: 736px) 100vw, 736px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h29.png 736w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h29-300x43.png 300w\" alt=\"\" width=\"736\" height=\"106\" title=\"\"><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"wait_command\"><\/span>Wait Command:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>wait is a built-in command of Linux that waits for completing any running process. wait command is used with a particular process id or job id. If no process id or job id is given with wait command then it will wait for all current child processes to complete and returns exit status. Create a file named \u2018wait_example.sh\u2019 and add the following script.<\/p>\n<div>\n<div>#!\/bin\/bash<br \/>\necho &#8220;Wait command&#8221; &amp;<br \/>\nprocess_id=$!<br \/>\nwait $process_id<br \/>\necho &#8220;Exited with status $?&#8221;<\/div>\n<\/div>\n<p>Run the file with bash command.<\/p>\n<div>\n<div>$ bash wait_example.sh<\/div>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h30.png\" sizes=\"(max-width: 727px) 100vw, 727px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h30.png 727w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h30-300x25.png 300w\" alt=\"\" width=\"727\" height=\"61\" title=\"\"><\/p>\n<p>You can check the following link to know more about wait command.<\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"sleep_command\"><\/span>Sleep Command:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>When you want to pause the execution of any command for specific period of time then you can use sleep command. You can set the delay amount by seconds (s), minutes (m), hours (h) and days (d). Create a file named \u2018sleep_example.sh\u2019 and add the following script. This script will wait for 5 seconds after running.<\/p>\n<div>\n<div>#!\/bin\/bash<\/p>\n<p>echo \u201cWait for 5 seconds\u201d<br \/>\nsleep 5<br \/>\necho \u201cCompleted\u201d<\/div>\n<\/div>\n<p>Run the file with bash command.<\/p>\n<div>\n<div>$ bash sleep_example.sh<\/div>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h31.png\" sizes=\"(max-width: 731px) 100vw, 731px\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h31.png 731w, https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/07\/h31-300x34.png 300w\" alt=\"\" width=\"731\" height=\"83\" title=\"\"><\/p>\n<p>You can check the following link to know more about sleep command.<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/sleep_command_linux\/\" target=\"_blank\" rel=\"noopener\">https:\/\/linuxhint.com\/sleep_command_linux\/<\/a><\/p>\n<p><a href=\"\/#TOP\">\u0628\u0627\u0632\u06af\u0634\u062a \u0628\u0647 \u0641\u0647\u0631\u0633\u062a<\/a><\/p>\n<p>Hope, after reading this article you have got a basic concept on bash scripting language and you will be able to apply them based on your requirements.<\/p>\n<\/div>\n<\/div>\n<footer>\n<div>\u00a0<\/div>\n<\/footer>\n<\/article>\n<p><\/main><\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-center kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;center&quot;,&quot;id&quot;:&quot;4202&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;89&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;3.9&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;\u0627\u0645\u062a\u06cc\u0627\u0632 \u0634\u0645\u0627 \u0628\u0647 \u0627\u06cc\u0646 \u0645\u0637\u0644\u0628&quot;,&quot;legend&quot;:&quot;3.9\\\/5 (89 \u0631\u0627\u06cc)&quot;,&quot;size&quot;:&quot;30&quot;,&quot;title&quot;:&quot;30 \u0646\u0645\u0648\u0646\u0647 \u062f\u0633\u062a\u0648\u0631 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a Bash - \u06cc\u0627\u062f\u06af\u06cc\u0631\u06cc \u0628\u0634 \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0628\u0627 \u0646\u0645\u0648\u0646\u0647&quot;,&quot;width&quot;:&quot;134&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} ({count} \u0631\u0627\u06cc)&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-left: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 30px; height: 30px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-left: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 30px; height: 30px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-left: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 30px; height: 30px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-left: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 30px; height: 30px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-left: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 30px; height: 30px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 134px;\">\n            <div class=\"kksr-star\" style=\"padding-left: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 30px; height: 30px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-left: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 30px; height: 30px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-left: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 30px; height: 30px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-left: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 30px; height: 30px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-left: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 30px; height: 30px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 24px;\">\n            3.9\/5 (89 \u0631\u0627\u06cc)    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">\u0632\u0645\u0627\u0646 \u0644\u0627\u0632\u0645 \u0628\u0631\u0627\u06cc \u0645\u0637\u0627\u0644\u0639\u0647: <\/span> <span class=\"rt-time\"> 12<\/span> <span class=\"rt-label rt-postfix\">\u062f\u0642\u06cc\u0642\u0647<\/span><\/span>\u0627\u0633\u06a9\u0631\u06cc\u067e\u062a \u0646\u0648\u06cc\u0633\u06cc \u0628\u0634 (Bash) \u0645\u06cc\u200e\u062a\u0648\u0627\u0646\u062f \u0628\u0631\u0627\u06cc \u0645\u0648\u0627\u0631\u062f \u0632\u06cc\u0627\u062f\u06cc \u0627\u0632 \u062c\u0645\u0644\u0647 \u0627\u062c\u0631\u0627\u06cc \u062f\u0633\u062a\u0648\u0631 Shell \u060c \u0627\u062c\u0631\u0627\u06cc \u0686\u0646\u062f\u06cc\u0646 \u062f\u0633\u062a\u0648\u0631 \u0628\u0627 \u0647\u0645 \u060c \u0633\u0641\u0627\u0631\u0634\u06cc \u0633\u0627\u0632\u06cc \u0648\u0638\u0627\u06cc\u0641 \u0645\u062f\u06cc\u0631\u06cc\u062a\u06cc \u060c \u0627\u062c\u0631\u0627\u06cc \u062a\u0633\u06a9 \u0647\u0627 \u0628\u0635\u0648\u0631\u062a \u0627\u062a\u0648\u0645\u0627\u062a\u06cc\u06a9 \u0648 &#8230; \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0634\u0648\u062f \u0628\u0647 \u0647\u0645\u06cc\u0646 \u062f\u0644\u06cc\u0644 \u062f\u0627\u0646\u0634 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc Bash \u0648 \u067e\u0627\u06cc\u0647 \u0622\u0646 \u0628\u0631\u0627\u06cc \u0647\u0631 \u06a9\u0627\u0631\u0628\u0631 \u0633\u06cc\u0633\u062a\u0645 \u0639\u0627\u0645\u0644 \u0644\u06cc\u0646\u0648\u06a9\u0633 \u0645\u0647\u0645 \u0627\u0633\u062a \u060c \u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[206,1062,620],"tags":[626,1059,1061,1060,487,1058],"class_list":["post-4202","post","type-post","status-publish","format-standard","hentry","category-development","category-bash-script","category-programming","tag-bash","tag-bash-scripting","tag--bash-scripting","tag--scripting","tag-487","tag-1058"],"acf":[],"_links":{"self":[{"href":"https:\/\/rasanegaar.com\/blog\/wp-json\/wp\/v2\/posts\/4202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rasanegaar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rasanegaar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rasanegaar.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/rasanegaar.com\/blog\/wp-json\/wp\/v2\/comments?post=4202"}],"version-history":[{"count":0,"href":"https:\/\/rasanegaar.com\/blog\/wp-json\/wp\/v2\/posts\/4202\/revisions"}],"wp:attachment":[{"href":"https:\/\/rasanegaar.com\/blog\/wp-json\/wp\/v2\/media?parent=4202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rasanegaar.com\/blog\/wp-json\/wp\/v2\/categories?post=4202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rasanegaar.com\/blog\/wp-json\/wp\/v2\/tags?post=4202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}