{"id":38274,"date":"2024-03-13T03:01:08","date_gmt":"2024-03-13T03:01:08","guid":{"rendered":"https:\/\/linuxsimply.com\/?p=38274"},"modified":"2024-03-13T08:01:14","modified_gmt":"2024-03-13T08:01:14","slug":"advanced-shell-script-examples","status":"publish","type":"post","link":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/","title":{"rendered":"Advanced Shell Script With Examples [Free Downloads]"},"content":{"rendered":"<p style=\"text-align: justify;\"><strong>Bash Scripting <\/strong>offers the concepts of string, array, and loops for achieving advanced programming goals. In this article, I will explore concepts and tools of the <strong>advanced shell script<\/strong> with examples that will elevate your shell scripting skills. I will equip you with the knowledge to tackle complex tasks.<\/p>\n<div class=\"su-note\"  style=\"border-color:#cedfe5;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#E8F9FF;border-color:#ffffff;color:#333333;\">\n<div class=\"su-row\"><div class=\"su-column su-column-size-1-2\"><div class=\"su-column-inner su-u-clearfix su-u-trim\">\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-38434\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/Advanced-Shell-Script-Free-DOWNLOAD.png\" alt=\"Advanced Shell Script Free download\" width=\"524\" height=\"346\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/Advanced-Shell-Script-Free-DOWNLOAD.png 524w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/Advanced-Shell-Script-Free-DOWNLOAD-300x198.png 300w\" sizes=\"(max-width: 524px) 100vw, 524px\" \/><\/p>\n<\/div><\/div>\n<div class=\"su-column su-column-size-1-2\"><div class=\"su-column-inner su-u-clearfix su-u-trim\">\n<p><span style=\"font-size: 18pt;\"><strong>Available Download Options<\/strong><\/span><\/p>\n<hr \/>\n<p><strong>Most Popular<\/strong><\/p>\n<a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/advanced-shell-script-example.pdf\" class=\"su-button su-button-style-default\" style=\"color:#000000;background-color:#FFFDF3;border-color:#cccbc3;border-radius:0px\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"color:#000000;padding:6px 18px;font-size:14px;line-height:21px;border-color:#fffef7;border-radius:0px;text-shadow:0px 0px 0px #000000\"><i class=\"sui sui-download\" style=\"font-size:14px;color:#1AA1D6\"><\/i> PDF (43 Pages)<\/span><\/a>\n<div class=\"su-spacer\" style=\"height:5px\"><\/div>\n<a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/advanced-shell-script-example.docx\" class=\"su-button su-button-style-default\" style=\"color:#000000;background-color:#FFFDF3;border-color:#cccbc3;border-radius:0px\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"color:#000000;padding:6px 18px;font-size:14px;line-height:21px;border-color:#fffef7;border-radius:0px;text-shadow:0px 0px 0px #000000\"><i class=\"sui sui-download\" style=\"font-size:14px;color:#1AA1D6\"><\/i> DOC (43 Pages)<\/span><\/a>\n<div class=\"su-spacer\" style=\"height:15px\"><\/div>\n<p><strong>Combo Pack<\/strong><\/p>\n<a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/advanced-shell-script-examples.zip\" class=\"su-button su-button-style-default\" style=\"color:#000000;background-color:#FFFDF3;border-color:#cccbc3;border-radius:0px\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"color:#000000;padding:7px 22px;font-size:17px;line-height:26px;border-color:#fffef7;border-radius:0px;text-shadow:0px 0px 0px #000000\"><i class=\"sui sui-download\" style=\"font-size:17px;color:#1AA1D6\"><\/i> ZIP (71 Scripts)<\/span><\/a>\n<\/div><\/div><\/div>\n<\/div><\/div>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#1_Find_the_Length_of_a_String\" >1. Find the Length of a String<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#2_Check_if_Two_Strings_are_Equal\" >2. Check if Two Strings are Equal<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#3_Convert_All_Uppercase_Letters_in_a_String_to_Lowercase\" >3. Convert All Uppercase Letters in a String to Lowercase<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#4_Remove_All_Whitespace_from_a_String\" >4. Remove All Whitespace from a String<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#5_Reverse_a_String\" >5. Reverse a String<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#6_Reverse_a_Sentence\" >6. Reverse a Sentence<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#7_Capitalize_the_First_Letter_of_a_Word\" >7. Capitalize the First Letter of a Word<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#8_Replace_a_Word_in_a_Sentence\" >8. Replace a Word in a Sentence<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#9_Print_Numbers_from_5_to_1\" >9. Print Numbers from 5 to 1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#10_Print_Even_Numbers_From_1_to_10\" >10. Print Even Numbers From 1 to 10<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#11_Print_the_Multiplication_Table_of_a_Number\" >11. Print the Multiplication Table of a Number<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#12_Calculate_the_Sum_of_Digits_of_a_Given_Number\" >12. Calculate the Sum of Digits of a Given Number<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#13_Calculate_the_Factorial_of_a_Number\" >13. Calculate the Factorial of a Number<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#14_Calculate_the_Sum_of_the_First_%E2%80%9Cn%E2%80%9D_Numbers\" >14. Calculate the Sum of the First \u201cn\u201d Numbers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#15_Find_the_Smallest_and_Largest_Elements_in_an_Array\" >15. Find the Smallest and Largest Elements in an Array<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#16_Sort_an_Array_of_Integers_in_Ascending_Order\" >16. Sort an Array of Integers in Ascending Order<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#17_Remove_an_Element_from_an_Array\" >17. Remove an Element from an Array<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#18_Inserting_an_Element_into_an_Array\" >18. Inserting an Element into an Array<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#19_Slicing_an_Array_Using_Bash_Script\" >19. Slicing an Array Using Bash Script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#20_Calculate_the_Average_of_an_Array_of_Numbers\" >20. Calculate the Average of an Array of Numbers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#21_Find_the_Length_of_an_Array\" >21. Find the Length of an Array<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#22_Check_if_a_String_is_a_Palindrome\" >22. Check if a String is a Palindrome<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#23_Check_if_a_Number_is_Prime\" >23. Check if a Number is Prime<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#24_Convert_Fahrenheit_to_Celsius\" >24. Convert Fahrenheit to Celsius<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#25_Calculate_the_Area_of_a_Rectangle\" >25. Calculate the Area of a Rectangle<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#26_Calculate_the_Area_of_a_Circle\" >26. Calculate the Area of a Circle<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#27_Grading_System\" >27. Grading System<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#28_Search_For_a_Pattern_inside_a_File\" >28. Search For a Pattern inside a File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#29_Replace_a_Pattern_in_a_Fille\" >29. Replace a Pattern in a Fille<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#30_Take_Multiple_Filenames_and_Prints_their_Contents\" >30. Take Multiple Filenames and Prints their Contents<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-31\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#31_Copy_a_File_to_a_New_Location\" >31. Copy a File to a New Location<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-32\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#32_Create_a_New_File_and_Write_Text_Inside\" >32. Create a New File and Write Text Inside<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-33\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#33_Compare_the_Contents_of_2_Given_Files\" >33. Compare the Contents of 2 Given Files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-34\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#34_Delete_a_Given_File_if_It_Exists\" >34. Delete a Given File if It Exists<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-35\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#35_Renames_a_File_from_Script\" >35. Renames a File from Script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-36\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#36_Check_the_Permissions_of_a_file\" >36. Check the Permissions of a file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-37\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#37_Set_the_Permissions_of_a_Directory_for_the_Owner\" >37. Set the Permissions of a Directory for the Owner<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-38\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#38_Change_the_File_Owner\" >38. Change the File Owner<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-39\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#39_File_Permissions_Change_the_Overall_Permissions_of_a_File\" >39. File Permissions: Change the Overall Permissions of a File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-40\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#40_Check_a_Remote_Host_for_its_Availability\" >40. Check a Remote Host for its Availability<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-41\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#41_Test_if_a_Remote_Port_is_Open\" >41. Test if a Remote Port is Open<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-42\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#42_Checking_Network_Connectivity\" >42. Checking Network Connectivity<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-43\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#43_Automating_Network_Configuration\" >43. Automating Network Configuration<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-44\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#44_Check_if_a_Process_is_Running\" >44. Check if a Process is Running<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-45\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#45_Start_a_Process_if_Its_Not_Already_Running\" >45. Start a Process if It&#8217;s Not Already Running<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-46\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#46_Stop_a_Process\" >46. Stop a Process<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-47\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#47_Restart_a_Process\" >47. Restart a Process<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-48\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#48_Monitor_a_Process_and_Restart_It_if_Crashes\" >48. Monitor a Process and Restart It if Crashes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-49\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#49_Display_the_Top_10_CPU-Consuming_Processes\" >49. Display the Top 10 CPU-Consuming Processes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-50\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#50_Display_the_Top_10_Memory-Consuming_Processes\" >50. Display the Top 10 Memory-Consuming Processes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-51\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#51_Kill_Processes_of_a_Specific_User\" >51. Kill Processes of a Specific User<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-52\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#52_Kill_All_Processes_that_are_Consuming_More_than_a_Certain_Amount_of_CPU\" >52. Kill All Processes that are Consuming More than a Certain Amount of CPU<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-53\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#53_Kill_All_Processes_that_are_Consuming_More_than_a_Certain_Amount_of_Memory\" >53. Kill All Processes that are Consuming More than a Certain Amount of Memory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-54\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#54_Check_the_Number_of_Logged-in_Users\" >54. Check the Number of Logged-in Users<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-55\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#55_Check_the_Operating_System_Information\" >55. Check the Operating System Information<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-56\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#56_Check_the_Systems_Memory_Usage\" >56. Check the System\u2019s Memory Usage<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-57\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#57_Check_the_Systems_Disk_Usage\" >57. Check the System\u2019s Disk Usage<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-58\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#58_Check_the_Systems_Network_Information\" >58. Check the System\u2019s Network Information<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-59\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#59_Check_the_Uptime\" >59. Check the Uptime<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-60\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#60_Check_the_System_Load_Average\" >60. Check the System Load Average<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-61\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#61_Check_the_System_Architecture\" >61. Check the System Architecture<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-62\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#62_Count_the_Number_of_Files_in_the_System\" >62. Count the Number of Files in the System<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-63\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#63_Automated_Backup\" >63. Automated Backup<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-64\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#64_Generate_Alert_if_Disk_Space_Usage_Goes_Over_a_Threshold\" >64. Generate Alert if Disk Space Usage Goes Over a Threshold<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-65\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#65_Create_a_New_User_and_Add_to_Sudo_Group\" >65. Create a New User and Add to Sudo Group<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-66\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#66_Monitor_Network_Traffic\" >66. Monitor Network Traffic<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-67\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#67_Monitor_CPU_and_Memory_Usage\" >67. Monitor CPU and Memory Usage<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-68\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#68_Creating_a_Script_and_Adding_It_to_PATH\" >68. Creating a Script and Adding It to PATH<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-69\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#69_Running_a_Command_at_Regular_Intervals\" >69. Running a Command at Regular Intervals<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-70\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#70_Downloading_Files_from_a_List_of_URLs\" >70. Downloading Files from a List of URLs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-71\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#71_Organize_Files_in_a_Directory_Based_on_Their_File_Types\" >71. Organize Files in a Directory Based on Their File Types<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-72\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-73\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#People_Also_Ask\" >People Also Ask<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-74\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#What_are_the_practical_uses_of_shell_scripting\" >What are the practical uses of shell scripting?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-75\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#Which_shell_scripting_language_is_the_most_popular_and_why\" >Which shell scripting language is the most popular and why?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-76\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#Can_we_compile_shell_script\" >Can we compile shell script?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-77\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#What_is_1_in_shell_script\" >What is $1 in shell script?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-78\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#What_is_the_difference_between_shell_script_and_bash_script\" >What is the difference between shell script and bash script?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"1_Find_the_Length_of_a_String\"><\/span>1. Find the Length of a String<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can simply use the <strong>${#STRING} <\/strong>to find the length of a string:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nstr=&quot;My name is Tom!&quot;\nlen=${#str}\necho &quot;The length of the string is: $len&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">The length of the string is: 15<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"2_Check_if_Two_Strings_are_Equal\"><\/span>2. Check if Two Strings are Equal<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Check whether two strings are the same or not using the <strong>== (Equal)<\/strong> operator inside the <strong>if <\/strong>condition:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nstring1=&quot;hello&quot;\nstring2=&quot;world&quot;\nif [ &quot;$string1&quot; == &quot;$string2&quot; ]; then\n\u00a0 echo &quot;The strings are equal.&quot;\nelse\n\u00a0 echo &quot;The strings are not equal.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">The strings are not equal.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"3_Convert_All_Uppercase_Letters_in_a_String_to_Lowercase\"><\/span>3. Convert All Uppercase Letters in a String to Lowercase<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Here is a bash script for converting all upper case letters in a string to lower case letters that use the <strong>tr <\/strong>command with the <strong>[:upper:] <\/strong>and <strong>[:lower:] <\/strong>classes for conversion:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter a string: &quot; str\necho &quot;Converted String:&quot; $str | tr &#039;[:upper:]&#039; &#039;[:lower:]&#039;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter a string: ABCDefgh\nconverted string: abcdefgh<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"4_Remove_All_Whitespace_from_a_String\"><\/span>4. Remove All Whitespace from a String<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">For removing white spaces from a string simply use the <strong>${STRING\/\/ \/}<\/strong>:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nstr=&quot;\u00a0\u00a0 Hello\u00a0\u00a0\u00a0 from Linuxsimply !\u00a0\u00a0 ! &quot;\nstr=${str\/\/ \/}\necho &quot;The resultant string: $str&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">The resultant string: HellofromLinuxsimply!!<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"5_Reverse_a_String\"><\/span>5. Reverse a String<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">To reverse a string use the <strong>rev <\/strong>command with <strong>echo <\/strong>and <strong>Pipe(|)<\/strong>:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nstr=&quot;Linuxsimply&quot;\nstr=$(echo &quot;$str&quot; | rev)\necho &quot;The reversed string: $str&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">The reversed string: ylpmisxuniL<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"6_Reverse_a_Sentence\"><\/span>6. Reverse a Sentence<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can reverse a sentence by reversing the order of words with the <strong>awk <\/strong>command. For instance:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nsentence=&quot;Hello from LinuxsimplY!!&quot;\nr_sentence=$(echo &quot;$sentence&quot; | awk &#039;{ for(i=NF;i&gt;0;i--) printf(&quot;%s &quot;,$i); print &quot;&quot; }&#039;)\necho &quot;The reversed sentence is: $r_sentence&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">The reversed sentence is: LinuxsimplY!! from Hello<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"7_Capitalize_the_First_Letter_of_a_Word\"><\/span>7. Capitalize the First Letter of a Word<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">For capitalizing only the first letter of a word, cut out the first letter to convert it and then concatenate it with the rest of the string. See the script below:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nstr=&quot;linuxsimply!!&quot;\ncap_str=$(echo &quot;${str:0:1}&quot; | tr &#039;[:lower:]&#039; &#039;[:upper:]&#039;)${str:1}\necho &quot;The capitalized word is: $cap_str&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">The capitalized word is: Linuxsimply!!<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"8_Replace_a_Word_in_a_Sentence\"><\/span>8. Replace a Word in a Sentence<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can replace the first occurrence of a word in a string with a given word using the <strong>$(..\/..\/..):<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter a sentence: &quot; str1\nread -p &quot;Enter the word to be replaced: &quot; str2\nread -p &quot;Enter the new word: &quot; str3\necho &quot;Modified sentence: ${str1\/$str2\/$str3}&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter a sentence: I love Linux\nEnter the word to be replaced: Linux\nEnter the new word: Linuxsimply\nModified sentence: I love Linuxsimply<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"9_Print_Numbers_from_5_to_1\"><\/span>9. Print Numbers from 5 to 1<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can use the <strong>\u201cuntil\u201d <\/strong>loop in bash to print a number sequence. In this case, specify the condition to stop the loop inside \u201c<strong>until [ ]<\/strong>\u201d. Such as:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nn=5\nuntil [ $n == 0 ]\ndo\n\u00a0 echo $n\n\u00a0 n=$((n-1))\ndone<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">5\n4\n3\n2\n1<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"10_Print_Even_Numbers_From_1_to_10\"><\/span>10. Print Even Numbers From 1 to 10<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">To print the even number in a range, check the even number condition inside the for loop before printing the number:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nfor (( i=1; i&lt;=10; i++ ))\ndo\n\u00a0 if [ $((i%2)) == 0 ]\n\u00a0 then\n\u00a0\u00a0\u00a0 echo $i\n\u00a0 fi\ndone<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">2\n4\n6\n8\n10<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"11_Print_the_Multiplication_Table_of_a_Number\"><\/span>11. Print the Multiplication Table of a Number<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Use the simple <strong>echo <\/strong>command inside a \u201c<strong>for<\/strong>\u201d loop to display the Multiplication Table of a number:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter a number: &quot; num\nfor (( i=1; i&lt;=10; i++ ))\ndo\n\u00a0 echo &quot;$num x $i = $((num*i))&quot;\ndone<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter a number: 12\n12 x 1 = 12\n12 x 2 = 24\n12 x 3 = 36\n12 x 4 = 48\n12 x 5 = 60\n12 x 6 = 72\n12 x 7 = 84\n12 x 8 = 96\n12 x 9 = 108\n12 x 10 = 120<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"12_Calculate_the_Sum_of_Digits_of_a_Given_Number\"><\/span>12. Calculate the Sum of Digits of a Given Number<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">For calculating the sum of digits of a given number, extract each digit using \u201c<strong>%<\/strong>\u201d operator and store the summation in a fixed variable using the loop. See the script below:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter a number: &quot; num\nsum=0\nwhile [ $num -gt 0 ]\ndo\n\u00a0 dig=$((num%10))\n\u00a0 sum=$((sum+dig))\n\u00a0 num=$((num\/10))\ndone\necho &quot;The sum of digits of the given number: $sum&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter a number: 1567\nThe sum of digits of the given number: 19<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"13_Calculate_the_Factorial_of_a_Number\"><\/span>13. Calculate the Factorial of a Number<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Calculate the factorial of a number by running multiplications inside a \u201c<strong>for<\/strong>\u201d loop:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter a number: &quot; num\ntemp=1\nfor (( i=1; i&lt;=$num; i++ ))\ndo\ntemp=$((temp*i))\ndone\necho &quot;The factorial of $num is: $temp&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter a number: 6\nThe factorial of 6 is: 720<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"14_Calculate_the_Sum_of_the_First_%E2%80%9Cn%E2%80%9D_Numbers\"><\/span>14. Calculate the Sum of the First \u201cn\u201d Numbers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">To calculate the sum of the first n numbers run a for loop and addition operation till n. For example:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter a number: &quot; num\nsum=0\nfor (( i=1; i&lt;=$num; i++ ))\ndo\nsum=$((sum + i))\ndone\necho &quot;Sum of first $num numbers: $sum&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter a number: 100\nSum of first 100 numbers: 5050<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"15_Find_the_Smallest_and_Largest_Elements_in_an_Array\"><\/span>15. Find the Smallest and Largest Elements in an Array<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">To find the smallest and largest element in a given array, first initialize a small and a large number. Then compare the array elements with these numbers inside any loop:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\narr=(24 27 84 11 99)\necho &quot;Given array: ${arr[*]}&quot;\ns=100000\nl=0\nfor num in &quot;${arr[@]}&quot;\ndo\n  if [ $num -lt $s ]\n  then\n    s=$num\n  fi\n  if [ $num -gt $l ]\n  then\n    l=$num\n  fi\ndone\necho &quot;The smallest element: $s&quot;\necho &quot;The largest: $l&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Given array: 24 27 84 11 99\nThe smallest element: 11\nThe largest: 99<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"16_Sort_an_Array_of_Integers_in_Ascending_Order\"><\/span>16. Sort an Array of Integers in Ascending Order<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can sort an array of integers by converting it into a list of integers using \u201c<strong>tr \u2018\\n\u2019<\/strong>\u201d. The list of integers is sorted with the \u201c<strong>sort -n<\/strong>\u201d command and then converted back into an array. Like the script below:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\narr=(24 27 84 11 99)\necho &quot;Given array: ${arr[*]}&quot;\narr=($(echo &quot;${arr[*]}&quot; | tr &#039; &#039; &#039;\\n&#039; | sort -n | tr &#039;\\n&#039; &#039; &#039;))\necho &quot;Sorted array: ${arr[*]}&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Given array: 24 27 84 11 99\nSorted array: 11 24 27 84 99<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"17_Remove_an_Element_from_an_Array\"><\/span>17. Remove an Element from an Array<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">In bash, you can simply remove an element from an array using the pattern substitution concept. The syntax <code class=\"\" data-line=\"\">${arr[@]\/$val}<\/code> contains all the elements of the original array \u201c<strong>arr<\/strong>\u201d except for any occurrences of the value <strong>$val<\/strong>. For instance:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\narr=(24 27 84 11 99)\necho &quot;Given array: ${arr[*]}&quot;\nread -p &quot;Enter an element to remove: &quot; val\narr=(&quot;${arr[@]\/$val}&quot;)\necho &quot;Resultant array: ${arr[*]}&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Given array: 24 27 84 11 99\nEnter an element to remove: 11\nResultant array: 24 27 84\u00a0 99<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"18_Inserting_an_Element_into_an_Array\"><\/span>18. Inserting an Element into an Array<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">For inserting an element into an array, split the array in the given index and insert the element:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\narr=(24 27 84 11 99)\necho &quot;Given array: ${arr[*]}&quot;\nread -p &quot;Enter an element to insert: &quot; new_val\nread -p &quot;Enter the index to insert the element: &quot; index\narr=(&quot;${arr[@]:0:$index}&quot; &quot;$new_val&quot; &quot;${arr[@]:$index}&quot;)\necho &quot;The updated array: ${arr[@]}&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">iven array: 24 27 84 11 99\nEnter an element to insert: 100\nEnter the index to insert the element: 3\nThe updated array: 24 27 84 100 11 99<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"19_Slicing_an_Array_Using_Bash_Script\"><\/span>19. Slicing an Array Using Bash Script<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Slice an array in Bash by placing the indices to slice inside the<strong> ${arr[@]:$index1:$index2} <\/strong>pattern:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\narr=(24 27 84 11 99)\necho &quot;Given array: ${arr[*]}&quot;\nread -p &quot;Enter 1st index of slice: &quot; index1\nread -p &quot;Enter 2nd index of slice: &quot; index2\nsliced_arr=(&quot;${arr[@]:$index1:$index2}&quot;)\necho &quot;The sliced array: ${sliced_arr[@]}&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Given array: 24 27 84 11 99\nEnter 1st index of slice: 1\nEnter 2nd index of slice: 3\nThe sliced array: 27 84 11<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"20_Calculate_the_Average_of_an_Array_of_Numbers\"><\/span>20. Calculate the Average of an Array of Numbers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Find the sum of array elements using a \u201c<strong>for<\/strong>\u201d loop and divide it by the number of elements i.e. <strong>${#arr[@]}<\/strong>:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\necho &quot;Enter an array of numbers (separated by space):&quot;\nread -a arr\nsum=0\nfor i in &quot;${arr[@]}&quot;\ndo\nsum=$((sum+i))\ndone\navg=$((sum\/${#arr[@]}))\necho &quot;Average of the array elements: $avg&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter an array of numbers (separated by space):\n23 45 11 99 100\nAverage of the array elements: 55<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"21_Find_the_Length_of_an_Array\"><\/span>21. Find the Length of an Array<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To find the length of an array simply use the syntax: <code class=\"\" data-line=\"\">${#arr[@]}<\/code>:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\narr=(24 27 84 11 99)\necho &quot;Given array: ${arr[*]}&quot;\nlen=${#arr[@]}\necho &quot;The length of the array: $len&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Given array: 24 27 84 11 99\nThe length of the array: 5<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"22_Check_if_a_String_is_a_Palindrome\"><\/span>22. Check if a String is a Palindrome<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Write the code to check a palindrome inside the function \u201c<strong>Palindrome()<\/strong>\u201d and call it by passing the desired string:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nPalindrome () {\ns=$1\nif [ &quot;$(echo $s | rev)&quot; == &quot;$str&quot; ]\nthen\necho &quot;The string is a Palindrome&quot;\nelse\necho &quot;The string is not a palindrome&quot;\nfi\n}\nread -p &quot;Enter a string: &quot; str\nPalindrome &quot;$str&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter a string: wow\nThe string is a Palindrome<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"23_Check_if_a_Number_is_Prime\"><\/span>23. Check if a Number is Prime<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Create the \u201c<strong>Prime()<\/strong>\u201d function that returns whether the parameter passed is prime or not:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nPrime () {\nnum=$1\nif [ $num -lt 2 ]\nthen\n  echo &quot;The number $num is Not Prime&quot;\n  return\nfi\nfor (( i=2; i&lt;=$num\/2; i++ ))\ndo\n  if [ $((num%i)) -eq 0 ]\n  then\n    echo &quot;The number $num is Not Prime&quot;\n    return\n  fi\ndone\necho &quot;The number $num is Prime&quot;\n}\nread -p &quot;Enter a number: &quot; num\nPrime &quot;$num&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter a number: 2\nThe number 2 is Prime<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"24_Convert_Fahrenheit_to_Celsius\"><\/span>24. Convert Fahrenheit to Celsius<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Here, the function \u201c<strong>Celsius()<\/strong>\u201d runs the necessary formula on the passed temperature value in Fahrenheit to convert it into Celsius:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nCelsius () {\n  f=$1\n  c=$((($f-32)*5\/9))\n  echo &quot;Temperature in Celsius = $c\u00b0C&quot;\n}\nread -p &quot;Enter temperature in Fahrenheit:&quot; f\nCelsius $f<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter temperature in Fahrenheit:100\nTemperature in Celsius = 37\u00b0C<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"25_Calculate_the_Area_of_a_Rectangle\"><\/span>25. Calculate the Area of a Rectangle<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Write the formula to calculate the area of a rectangle inside the function \u201c<strong>Area()<\/strong>\u201d and call it by passing the height and width:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nArea() {\nwidth=$1\nheight=$2\narea=$(($width * $height))\necho \u201cArea of the rectangle is: $area\u201d\n}\nread -p &quot;Enter height and width of the ractangle:&quot; h w\nArea $h $w<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter height and width of the ractangle:10 4\n\u201cArea of the rectangle is: 40\u201d<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"26_Calculate_the_Area_of_a_Circle\"><\/span>26. Calculate the Area of a Circle<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Write the formula to calculate the area of a circle inside the function \u201c<strong>Area()<\/strong>\u201d and call it by passing the given radius:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nArea () {\nradius=$1\narea=$(echo &quot;scale=2; 3.14 * $radius * $radius&quot; | bc)\necho &quot;Area of a circle with radius $radius is $area.&quot;\n}\nread -p &quot;Enter radius of the circle:&quot; r\nArea $r<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter radius of the circle:4\nArea of a circle with radius 4 is 50.24.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"27_Grading_System\"><\/span>27. Grading System<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The function \u201c<strong>Grade()<\/strong>\u201d runs the necessary conditions to divide the number ranges into grades and returns the resultant grade:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nGrade() {\nscore=$1\nif (( $score &gt;= 80 )); then\n  grade=&quot;A+&quot;\nelif (( $score &gt;= 70 )); then\n  grade=&quot;A&quot;\nelif (( $score &gt;= 60 )); then\n  grade=&quot;B&quot;\nelif (( $score &gt;= 50 )); then\n  grade=&quot;C&quot;\nelif (( $score &gt;= 40 )); then\n  grade=&quot;D&quot;\nelse\n  grade=&quot;F&quot;\nfi\necho \u201cThe grade for mark $s is $grade\u201d\n}\nread -p &quot;Enter a score between 1-100:&quot; s\nGrade $s<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter a score between 1-100:76\n\u201cThe grade for mark 76 is A\u201d<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"28_Search_For_a_Pattern_inside_a_File\"><\/span>28. Search For a Pattern inside a File<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script given below will take a filename and a pattern as user input and search it within the file. If the pattern is found then the lines having the pattern will be displayed on the screen along with line numbers. Otherwise, it will print a message saying the pattern did not match. See the script below:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter filename: &quot; filename\nread -p &quot;Enter a pattern to search for: &quot; pattern\ngrep -w -n $pattern $filename\nif [ $? -eq 1 ]; then\n  echo &quot;Pattern did not match.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter filename: poem.txt\nEnter a pattern to search for: daffodils\n4:A host, of golden daffodils;\n27:And dances with the daffodils.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"29_Replace_a_Pattern_in_a_Fille\"><\/span>29. Replace a Pattern in a Fille<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following script will take a file name and a pattern from the user to replace it with a new pattern. Finally, it will display the updated lines on the terminal. If the pattern to replace does not exist, then it will show an error message:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter filename: &quot; filename\nread -p &quot;Enter a pattern to replace: &quot; pattern\nread -p &quot;Enter new pattern: &quot; new_pattern\ngrep -q $pattern $filename\nif [ $? -eq 0 ]; then\n  sed -i &quot;s\/$pattern\/$new_pattern\/g&quot; $filename\n  echo &quot;Updated Lines: &quot;\n  grep -w -n $new_pattern $filename\nelse\n  echo &quot;Error! Pattern did not match.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter filename: poem.txt\nEnter a pattern to replace: daffodils\nEnter new pattern: dandelions\nUpdated Lines:\n4:A host, of golden dandelions;\n27:And dances with the dandelions.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"30_Take_Multiple_Filenames_and_Prints_their_Contents\"><\/span>30. Take Multiple Filenames and Prints their Contents<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The below script is for reading the contents of multiple files. It will take the file names as user input and display their contents on the screen. If any filename does not exist, it will show a separate error message for that file. For example:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter the file names: &quot; files\nIFS=&#039; &#039; read -ra array &lt;&lt;&lt; &quot;$files&quot;\nfor file in &quot;${array[@]}&quot;\ndo\nif [ -e &quot;$file&quot; ]; then\n  echo &quot;Contents of $file:&quot;\n  cat &quot;$file&quot;\nelse\n  echo &quot;Error: $file does not exist&quot;\nfi\ndone<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter the file names: message.txt passage.txt\nContents of message.txt:\n\u201cMerry Christmas! May your happiness be large and your bills be small.\u201d\nContents of passage.txt:\nThe students told the headmaster that they wanted to celebrate the victory of the National Debate Competition.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"31_Copy_a_File_to_a_New_Location\"><\/span>31. Copy a File to a New Location<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can copy a file to another location using the bash script below. It will read the filename and destination path from the terminal and copy the file if it exists in the current directory. If the file is not there, the script will return an error message. Such as:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter the file name: &quot; file\nread -p &quot;Enter destination path:&quot; dest\nif [ -e &quot;$file&quot; ]; then\n  cp $file $dest\n  file_location=$(readlink -f $dest)\n  echo &quot;A copy of $file is now located att: $file_location&quot;\nelse\n  echo &quot;Error: $file does not exist&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter the file name: poem.txt\nEnter destination path:\/home\/susmit\/Documents\nA copy of poem.txt is now located at: \/home\/susmit\/Documents<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"32_Create_a_New_File_and_Write_Text_Inside\"><\/span>32. Create a New File and Write Text Inside<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script given below is for creating a new file and writing text inside the file. You will be able to write into the file from the command line. Upon completion, it will show a message saying the file has been created. Following is the full script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter the file name: &quot; file\necho &quot;Enter text to write:&quot;\nread text\necho &quot;$text&quot; &gt; &quot;$file&quot;\necho &quot;-----------------------------------&quot;\necho &quot;The File $file is created!&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter the file name: text_file1.txt\nEnter text to write:\nIn English, there are three articles: a, an, and the. Articles are used before nouns or noun equivalents and are a type of adjective. The definite article (the) is used before a noun to indicate that the identity of the noun is known to the reader.\n-----------------------------------\nThe File text_file1.txt is created!<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"33_Compare_the_Contents_of_2_Given_Files\"><\/span>33. Compare the Contents of 2 Given Files<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following bash script takes two file names as user input and compares their contents. If one or either of the files does not exist in the current directory it shows an error to the user. Otherwise, prints the result if the files are identical or not. Such as:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter the 1st file name: &quot; file1\nread -p &quot;Enter the 2nd file name: &quot; file2\nif [ ! -f $file1 ] || [ ! -f $file2 ]\nthen\n  echo &quot;Error! One of the files does not exists.&quot;\n  exit 1\nfi\nif cmp -s &quot;$file1&quot; &quot;$file2&quot;\nthen\n  echo &quot;The Files $file1 and $file2 are identical.&quot;\nelse\n  echo &quot;The Files $file1 and $file2 are different.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter the 1st file name: article1.txt\nEnter the 2nd file name: text_file1.txt\nThe Files article1.txt and text_file1.txt are identical.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"34_Delete_a_Given_File_if_It_Exists\"><\/span>34. Delete a Given File if It Exists<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">This is a script for checking a file&#8217;s existence before running deleting the file. The script will take the file\u2019s name from the user and delete it if it is found in the current directory. Otherwise, it will display an error. See the code below:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nread -p &quot;Enter the file name for deletion: &quot; file\nif [ -f $file ]\nthen\n  rm $file\n  echo &quot;The file $file deleted successfully!&quot;\nelse\n  echo &quot;Error! The file $file does not exist.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter the file name for deletion: article1.txt\nThe file article1.txt deleted successfully!<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"35_Renames_a_File_from_Script\"><\/span>35. Renames a File from Script<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can rename an existing file using the script below. All you have to do is enter the old filename and the new filename. The script will rename the file if it is available in the directory. If the file is not in the path, then it will display an error message:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter the file name: &quot; file\nread -p &quot;Enter new file name: &quot; new_file\nif [ -f $file ]\nthen\n  mv &quot;$file&quot; &quot;$new_file&quot;\n  echo &quot;The file $file has been renamed as $new_file!&quot;\nelse\n  echo &quot;Error! The file $file does not exist.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter the file name: poem.txt\nEnter new file name: daffodils.txt\nThe file poem.txt has been renamed as daffodils.txt!<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"36_Check_the_Permissions_of_a_file\"><\/span>36. Check the Permissions of a file<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script below checks permissions for the given filename and lists the active permissions of the current user. If there does not exist any file of the input file name, then it displays an error message. For instance:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nread -p &quot;Enter the file name: &quot; file\nif [ -f $file ]; then\n  if [ -r &quot;$file&quot; ]; then\n    echo &quot;Readable&quot;\n  fi\n  if [ -w &quot;$file&quot; ]; then\n    echo &quot;Writable&quot;\n  fi\n  if [ -x &quot;$file&quot; ]; then\n    echo &quot;Executable&quot;\n  fi\n  else\n  echo &quot;Error! The file $file does not exist.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter the file name: daffodils.txt\nReadable\nWritable<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"37_Set_the_Permissions_of_a_Directory_for_the_Owner\"><\/span>37. Set the Permissions of a Directory for the Owner<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following script gives the current user read, write, and execute permissions of a directory. The directory name is taken as user input and if the directory does not exist, it displays an error message:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter the directory name: &quot; dir\nif [ -d $dir ]; then\n  chmod u+rwx $dir\n  echo &quot;Directory permissions have been updated!&quot;\nelse\n  echo &quot;Error! The directory $dir does not exist.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter the directory name: Documents\nDirectory permissions have been updated!<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"38_Change_the_File_Owner\"><\/span>38. Change the File Owner<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script here changes the owner of a file if the file exists in the directory. Since changing ownership requires administrator permissions, you will need to give the <strong>sudo <\/strong>password while running the script. Upon completion of the task, the script will show a success message:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter the file name: &quot; file\nread -p &quot;Enter file owner name: &quot; owner\nif [ -f $file ]; then\n  sudo chown $owner $file\n  echo &quot;Changed file owner to $owner!&quot;\nelse\n  echo &quot;Error! The file $file does not exist.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter the file name: daffodils.txt\nEnter file owner name: tom\n[sudo] password for susmit:\nChanged file owner to tom!<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"39_File_Permissions_Change_the_Overall_Permissions_of_a_File\"><\/span>39. File Permissions: Change the Overall Permissions of a File<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can change the permissions of an existing file using the script below. All you have to do is enter the filename, the permissions in <strong>absolute mode, <\/strong>and the <strong>sudo <\/strong>password to activate administrative privileges. The script will update the file permissions if it is available in the directory. If the file is not in the path, then it will display an error message:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter the file name: &quot; file\nread -p &quot;Enter new permissions in Absolute Mode: &quot; permissions\nif [ -f $file ]; then\n  sudo chmod $permissions $file\n  echo &quot;Permissions for the file $file has been changed!&quot;\nelse\n  echo &quot;Error! The file $file does not exist.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter the file name: daffodils.txt\nEnter new permissions in Absolute Mode: 777\n[sudo] password for susmit:\nPermissions for the file daffodils.txt has been changed!<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"40_Check_a_Remote_Host_for_its_Availability\"><\/span>40. Check a Remote Host for its Availability<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following script checks the network status of a remote host. You will need to enter the host IP address as input and it will return a message saying if the host is up or down:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter remote host IP address:&quot; ip\nping -c 1 $ip\nif [ $? -eq 0 ]\nthen\n  echo &quot;-----------------------&quot;\n  echo &quot;Host is up!&quot;\n  echo &quot;-----------------------&quot;\nelse\n  echo &quot;-----------------------&quot;\n  echo &quot;Host is down!&quot;\n  echo &quot;-----------------------&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter remote host IP address:192.168.0.6\nPING 192.168.0.6 (192.168.0.6) 56(84) bytes of data.\n64 bytes from 192.168.0.6: icmp_seq=1 ttl=64 time=4.10 ms\n--- 192.168.0.6 ping statistics ---\n1 packets transmitted, 1 received, 0% packet loss, time 0ms\nrtt min\/avg\/max\/mdev = 4.095\/4.095\/4.095\/0.000 ms\n-----------------------\nHost is up!\n-----------------------<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"41_Test_if_a_Remote_Port_is_Open\"><\/span>41. Test if a Remote Port is Open<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script below checks the network connection in a system port. It takes a host address and port number as the input. If the connection to the host through the port number is successful then it verifies that the port is open. Otherwise, it returns a message saying the port is closed:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter host address:&quot; HOST\nread -p &quot;Enter port number:&quot; PORT\nnc -z -v -w5 &quot;$HOST&quot; &quot;$PORT&quot;\nif [ $? -eq 0 ]; then\n  echo &quot;----------------------------------------------&quot;\n  echo &quot;Port $PORT on $HOST is open&quot;\n  echo &quot;----------------------------------------------&quot;\nelse\n  echo &quot;----------------------------------------------&quot;\n  echo &quot;Port $PORT on $HOST is closed&quot;\n  echo &quot;----------------------------------------------&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter host address:192.168.0.107\nEnter port number:80\nConnection to 192.168.0.107 80 port [tcp\/http-alt] succeeded!\n----------------------------------------------\nPort 80 on 192.168.0.107 is open\n----------------------------------------------<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"42_Checking_Network_Connectivity\"><\/span>42. Checking Network Connectivity<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The below script checks network connectivity to a remote host via the internet. If there is a successful connection then it returns the status \u201cInternet connection is up\u201d. Otherwise, returns \u201cInternet connection is down\u201d:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter a host address:&quot; HOST\nif ping -q -c 1 -W 1 $HOST &gt;\/dev\/null; then\n  echo &quot;----------------------------------------------&quot;\n  echo &quot;Internet connection is up&quot;\n  echo &quot;----------------------------------------------&quot;\nelse\n  echo &quot;----------------------------------------------&quot;\n  echo &quot;Internet connection is down&quot;\n  echo &quot;----------------------------------------------&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter a host address:192.168.0.107\n----------------------------------------------\nInternet connection is up\n----------------------------------------------<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"43_Automating_Network_Configuration\"><\/span>43. Automating Network Configuration<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following bash script configures a network IP address and subnet mask. Upon configuration, it sets up the gateway and DNS server at the given addresses. All four IP addresses are passed as user input. It will return an error message if it is unsuccessful at running any of the commands:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\necho &quot;Enter network configuration variables:&quot;\nread -p &quot;Enter an IP address: &quot; ip_addr\nread -p &quot;Enter a subnet mask: &quot; subnet_mask\nread -p &quot;Enter a Gateway address: &quot; gateway\nread -p &quot;Enter a DNS address: &quot; dns\n# Configure network interface\nsudo ifconfig eth0 $ip_addr netmask $subnet_mask up\nif [ $? -eq 0 ]; then\n# Set default gateway\n  sudo route add default gw $gateway\n  if [ $? -eq 0 ]; then\n  # Set DNS servers\n  sudo echo &quot;nameserver $dns&quot; &gt; \/etc\/resolv.conf\n    if [ $? -eq 0 ]; then\n      echo &quot;----------------------------------------------&quot;\n      echo &quot;Network configuration completed&quot;\n      echo &quot;----------------------------------------------&quot;\n    else\n      echo &quot;----------------------------------------------&quot;\n      echo &quot;Error while setting the DNS server.&quot;\n    fi\n  else\n    echo &quot;----------------------------------------------&quot;\n    echo &quot;Error while setting the default gateway.&quot;\n  fi\n  else\n    echo &quot;----------------------------------------------&quot;\n    echo &quot;Network Configuration Failed.&quot;\nfi<\/code><\/pre>\n<p><strong>Syntax to run the script: <\/strong><code class=\"\" data-line=\"\">sudo bash bin\/adv_example16.sh <\/code><\/p>\n<p><strong>Requirement: <\/strong><a href=\"https:\/\/linuxsimply.com\/ifconfig-command-in-linux\/#Installing_the_ifconfig_Command_in_Linux\" target=\"_blank\" rel=\"noopener\">ifconfig must be installed.<\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter network configuration variables:\nEnter an IP address: 192.168.0.108\nEnter a subnet mask: 255.255.255.0\nEnter a Gateway address: 192.168.0.1\nEnter a DNS address: 8.8.8.8\n----------------------------------------------\nNetwork configuration completed\n----------------------------------------------<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"44_Check_if_a_Process_is_Running\"><\/span>44. Check if a Process is Running<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The given script can check if a process is currently running on your system or not. You will need to enter your desired process name and the script will display the process\u2019s current status:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter process name: &quot; process\nif pgrep $process &gt; \/dev\/null\nthen\n  echo &quot;Process is running.&quot;\nelse\n  echo &quot;Process is not running.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter process name: bash\nProcess is running.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"45_Start_a_Process_if_Its_Not_Already_Running\"><\/span>45. Start a Process if It&#8217;s Not Already Running<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You can use the script given below to start a process. The process name is passed as user input to the script. If the process is already running then it will return a message saying \u201cThe Process is already running\u201d. Otherwise, It will start the desired process.<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter process name: &quot; process\nif ! pgrep $process &gt; \/dev\/null\nthen\n  \/path\/to\/process_name &amp;\n  echo &quot;The Process $process has now started.&quot;\nelse\n  echo &quot;The Process is already running.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter process name: bash\nThe Process is already running.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"46_Stop_a_Process\"><\/span>46. Stop a Process<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script below can stop a process if it runs in the system. The user has to enter a process name as the script input. If the process is currently running then the script will terminate that process. Otherwise, it says, \u201cThe process is not running\u201d:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter process name: &quot; process\nif pgrep $process &gt; \/dev\/null\nthen\n  pkill $process\n  echo &quot;The Process $process has stopped.&quot;\nelse\n  echo &quot;The Process $process is not running.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter process name: nslookup\nThe Process nslookup has stopped.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"47_Restart_a_Process\"><\/span>47. Restart a Process<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following script aims to take a process name as input and then restart it. If the process is already running then the script kills the process and starts over. After the first kill command, it waits for 5 seconds. If by then the process does not terminate then it will force kill that process before restarting:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter process name: &quot; process\npid=$(pgrep -f $process)\nif [ -n &quot;$pid&quot; ]; then\n  kill $pid\n  sleep 5\n  if pgrep -f $process&gt; \/dev\/null; then\n    echo &quot;Process did not exit properly, force killing...&quot;\n    kill -9 $pid\n  fi\nfi\nprocess_path=$(which $process)\n$process_path &amp; echo &quot;Process restarted.&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter process name: firefox\nProcess restarted.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"48_Monitor_a_Process_and_Restart_It_if_Crashes\"><\/span>48. Monitor a Process and Restart It if Crashes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script here takes a process name as input from the user and checks for its status every 5 seconds. If the process is running without any issues then it shows a message saying \u201cThe process is running\u201d. Otherwise, it restarts the process and continues to check its status again:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter process name: &quot; process\nprocess_path=$(which $process)\nwhile true\ndo\n  if pgrep $process &gt; \/dev\/null\n  then\n    echo &quot;The Process $process is running.&quot;\n    sleep 5\n  else\n    $process_path &amp;\n    echo &quot;The Process $process restarted.&quot;\n    continue\n  fi\ndone<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter process name: firefox\nThe Process firefox is running.\nThe Process firefox is running.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"49_Display_the_Top_10_CPU-Consuming_Processes\"><\/span>49. Display the Top 10 CPU-Consuming Processes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script below lists the top 10 CPU-consuming processes. It prints the Process ID, the percentage of CPU usage along with the command that runs each process. See the full script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\necho &quot;The current top 10 CPU-consuming processes: &quot;\nps -eo pid,%cpu,args | sort -k 2 -r | head -n 11<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">The current top 10 CPU-consuming processes:\nPID %CPU COMMAND\n2161\u00a0 0.6 \/usr\/bin\/gnome-shell\n1126\u00a0 0.5 \/usr\/sbin\/mysqld\n7593\u00a0 0.5 \/usr\/libexec\/gnome-terminal-server\n832\u00a0 0.2 \/usr\/bin\/java -Djava.awt.headless=true -jar \/usr\/share\/java\/jenkins.war --webroot=\/var\/cache\/jenkins\/war --httpPort=8080\n668\u00a0 0.1 \/usr\/bin\/vmtoolsd\n5498\u00a0 0.1 gjs \/usr\/share\/gnome-shell\/extensions\/ding@rastersoft.com\/ding.js -E -P \/usr\/share\/gnome-shell\/extensions\/ding@rastersoft.com -M 0 -D 0:0:1918:878:1:34:0:0:0:0\n104\u00a0 0.0 [zswap-shrink]\n86\u00a0 0.0 [xenbus_probe]\n26\u00a0 0.0 [writeback]\n39\u00a0 0.0 [watchdogd]<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"50_Display_the_Top_10_Memory-Consuming_Processes\"><\/span>50. Display the Top 10 Memory-Consuming Processes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The given script lists the top 10 memory-consuming processes. It prints the Process ID, percentage of memory usage as well as the commands for running each process:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\necho &quot;The current top 10 Memory-consuming processes: &quot;\nps -eo pid,%mem,args | sort -k 2 -r | head -n 11<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">The current top 10 Memory-consuming processes:\nPID %MEM COMMAND\n1126\u00a0 9.7 \/usr\/sbin\/mysqld\n832\u00a0 6.8 \/usr\/bin\/java -Djava.awt.headless=true -jar \/usr\/share\/java\/jenkins.war --webroot=\/var\/cache\/jenkins\/war --httpPort=8080\n2161\u00a0 6.7 \/usr\/bin\/gnome-shell\n2516\u00a0 2.1 \/usr\/bin\/Xwayland :0 -rootless -noreset -accessx -core -auth \/run\/user\/1000\/.mutter-Xwaylandauth.G8UR41 -listen 4 -listen 5 -displayfd 6 -initfd 7\n2585\u00a0 1.9 \/usr\/libexec\/gsd-xsettings\n1209\u00a0 1.5 \/usr\/bin\/dockerd -H fd:\/\/ --containerd=\/run\/containerd\/containerd.sock\n5498\u00a0 1.5 gjs \/usr\/share\/gnome-shell\/extensions\/ding@rastersoft.com\/ding.js -E -P \/usr\/share\/gnome-shell\/extensions\/ding@rastersoft.com -M 0 -D 0:0:1918:878:1:34:0:0:0:0\n2966\u00a0 1.4 \/usr\/bin\/gedit --gapplication-service\n7593\u00a0 1.3 \/usr\/libexec\/gnome-terminal-server\n2381\u00a0 1.3 \/usr\/libexec\/evolution-data-server\/evolution-alarm-notify<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"51_Kill_Processes_of_a_Specific_User\"><\/span>51. Kill Processes of a Specific User<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following script is created to kill all the processes of a specific user. The Specified username is taken as user input. After receiving the username, all the running processes of that user are terminated:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter username: &quot; user\nsudo pkill -u $user\necho &quot;All processes of user $user have been terminated.&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter username: tom\n[sudo] password for susmit:\nAll processes of user tom have been terminated.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"52_Kill_All_Processes_that_are_Consuming_More_than_a_Certain_Amount_of_CPU\"><\/span>52. Kill All Processes that are Consuming More than a Certain Amount of CPU<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">This script takes a CPU usage percentage as user input and terminates all the running processes that are consuming more than the entered CPU threshold. If there is no process above that threshold, then it returns a message saying there are no such processes:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter CPU usage threshold: &quot; threshold\nif [ &quot;$(ps -eo pid,%cpu | awk -v t=$threshold &#039;$2 &gt; t {print $1}&#039; | \n  wc -c)&quot; -gt 0 ]; then\n  for pid in $(ps -eo pid,%cpu | awk -v t=$threshold &#039;$2 &gt; t {print $1}&#039;)\n  do\n    kill $pid\n  done\n  echo &quot;All processes consuming more than $threshold% CPU killed.&quot;\nelse\n  echo &quot;There are no process consuming more than $threshold% CPU.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter CPU usage threshold: 10\nThere are no process consuming more than 10% CPU.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"53_Kill_All_Processes_that_are_Consuming_More_than_a_Certain_Amount_of_Memory\"><\/span>53. Kill All Processes that are Consuming More than a Certain Amount of Memory<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">This script takes a memory space percentage as user input and terminates all the running processes that are consuming more than the entered space threshold. If there is no process above that threshold, then it returns a message saying there are no such processes:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nread -p &quot;Enter memory usage threshold (in KB): &quot; threshold\nif [ &quot;$(ps -eo pid,%mem | awk -v t=$threshold &#039;$2 &gt; t {print $1}&#039; | wc -c)&quot; -gt 0 ]; then\n\n  for pid in $(ps -eo pid,%mem | awk -v t=$threshold &#039;$2 &gt; t {print $1}&#039;)\n\n  do\n    kill $pid\n  done\n  echo &quot;All processes consuming more than $threshold KB memory killed.&quot;\n  else\n  echo &quot;There are no process consuming more than $threshold KB memory.&quot;\nfi<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter memory usage threshold (in KB): 10\nThere are no process consuming more than 10 KB memory.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"54_Check_the_Number_of_Logged-in_Users\"><\/span>54. Check the Number of Logged-in Users<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">View the find the number of logged-in users in your system with the script below. It counts the users that are logged in only at the current time:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nusers=$(who | wc -l)\necho &quot;Number of currently logged-in users: $users&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Number of currently logged-in users: 2<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"55_Check_the_Operating_System_Information\"><\/span>55. Check the Operating System Information<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The following script displays information regarding the machine\u2019s operating system. It retrieves and lists the OS name, release, version as well and system architecture:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nos_name=$(uname -s)\nos_release=$(uname -r)\nos_version=$(cat \/etc\/*-release | grep VERSION_ID | cut -d &#039;&quot;&#039; -f 2)\nos_arch=$(uname -m)\necho &quot;OS Name: $os_name&quot;\necho &quot;OS Release: $os_release&quot;\necho &quot;OS Version: $os_version&quot;\necho &quot;OS Architecture: $os_arch&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">OS Name: Linux\nOS Release: 5.19.0-38-generic\nOS Version: 22.04\nOS Architecture: x86_64<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"56_Check_the_Systems_Memory_Usage\"><\/span>56. Check the System\u2019s Memory Usage<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script given below calculates the percentage of memory being used. The \u201c<strong>$3*100\/$2<\/strong>\u201d expression converts the usage into percentages and displays the output with two decimal places:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nmem=$(free -m | awk &#039;NR==2{printf &quot;%.2f%%&quot;, $3*100\/$2}&#039;)\necho &quot;Current Memory Usage: $mem&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Current Memory Usage: 72.48%<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"57_Check_the_Systems_Disk_Usage\"><\/span>57. Check the System\u2019s Disk Usage<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following script displays the percentage of disk space used on the root (\/) file system. It gets the file system\u2019s disk space usage in a human-readable format and prints only the used percentage:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\ndisk=$(df -h | awk &#039;$NF==&quot;\/&quot;{printf &quot;%s&quot;, $5}&#039;)\necho &quot;Current Disk Usage: $disk&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Current Disk Usage: 80%<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"58_Check_the_Systems_Network_Information\"><\/span>58. Check the System\u2019s Network Information<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Use the script below to get the network information of your system. It lists the system\u2019s IP address, Gateway address, and DNS server address:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\necho &quot; System\u2019s network information:-&quot;\nip=$(hostname -I)\necho &quot;IP Address: $ip&quot;\ngw=$(ip route | awk &#039;\/default\/ { print $3 }&#039;)\necho &quot;Gateway: $gw&quot;\ndns=$(grep &quot;nameserver&quot; \/etc\/resolv.conf | awk &#039;{print $2}&#039;)\necho &quot;DNS Server: $dns&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">System\u2019s network information:-\nIP Address: 192.168.0.109\nGateway: 192.168.0.1\nDNS Server: 127.0.0.53<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"59_Check_the_Uptime\"><\/span>59. Check the Uptime<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The given script can be used to find out the uptime of the system. It will return two values. The first one is the current time, and the second one is the uptime i.e. for how long the system has been running. In this example, \u201c<strong>up 16:19<\/strong>\u201d indicates that the system has been up for 16 hours and 19 minutes. See the full script below:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nuptime | awk &#039;{print $1,$2,$3}&#039; | sed &#039;s\/,\/\/&#039;\necho &quot;Uptime: $uptime&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Uptime: 00:16:38 up 16:19<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"60_Check_the_System_Load_Average\"><\/span>60. Check the System Load Average<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following script returns the system\u2019s Load Average. It will extract the load averages for the past 1, 5, and 15 minutes from the system\u2019s uptime and display their average on the screen:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nloadavg=$(uptime | awk &#039;{print $10,$11,$12}&#039;)\necho &quot;Load Average: $loadavg&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Load Average: 0.36<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"61_Check_the_System_Architecture\"><\/span>61. Check the System Architecture<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">To determine your current machine&#8217;s architecture you can run the following script. It returns the system\u2019s architecture. In this example, <strong>x86_64<\/strong> indicates that the machine is using the 64-bit version of the x86 architecture:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\narch=$(uname -m)\necho &quot;System Architecture: $arch&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">System Architecture: x86_64<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"62_Count_the_Number_of_Files_in_the_System\"><\/span>62. Count the Number of Files in the System<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can use the script below to find the available number of files on your machine. It runs the find command to check every file on the system and returns the total file count:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\ncount=$(find \/ -type f | wc -l)\necho &quot;Number of files in the system: $count.&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Number of files in the system: 500090.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"63_Automated_Backup\"><\/span>63. Automated Backup<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following script creates a backup file of a given directory. The source directory path and the destination directory path are user inputs. The backup file is named along with the current date for keeping track. Upon completion of the task, it returns the path where the backup archive resides:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter path of the directory to backup: &quot; source_dir\nread -p &quot;Enter destination path for backup: &quot; backup_dir\ndate=$(date +%Y-%m-%d)\nbackup_file=&quot;backup-$date.tar.gz&quot;\n# Create backup directory if it doesn&#039;t exist\nif [ ! -d &quot;$backup_dir&quot; ]; then\n  mkdir -p &quot;$backup_dir&quot;\nfi\n# Create backup archive\ntar -czf &quot;$backup_dir\/$backup_file&quot; &quot;$source_dir&quot;\necho &quot;Completed Creating backup at: $backup_dir.&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter path of the directory to backup: \/home\/susmit\/Documents\nEnter destination path for backup: \/home\/susmit\/Desktop\ntar: Removing leading `\/&#039; from member names\nCompleted Creating backup at: \/home\/susmit\/Desktop.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"64_Generate_Alert_if_Disk_Space_Usage_Goes_Over_a_Threshold\"><\/span>64. Generate Alert if Disk Space Usage Goes Over a Threshold<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script below generates an alert if the disk space usage goes over a threshold. It takes the threshold and a filename from the user. The alert is then generated in that file along with the disk space usage. If the space consumed is less than the threshold than the file remains empty:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter filename to write alert: &quot; file\ntouch $file\nread -p &quot;Enter disk space threshold: &quot; threshold\ndf -H | grep -vE &quot;^Filesystem|tmpfs|cdrom&quot; | awk &#039;{ print $5 &quot; &quot; $1 }&#039; | while read output;\ndo\nusage=$(echo $output | awk &#039;{ print $1}&#039; | cut -d&#039;%&#039; -f1)\nif [ $usage -ge $threshold ]; then\n  partition=$(echo $output | awk &#039;{ print $2 }&#039;)\n  echo &quot;Alert for \\&quot;$partition: Almost out of disk space $usage% as on $(date) &quot; &gt;&gt; $file\n  break\nfi\ndone\ncat $file<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter filename to write alert: alert.log\nEnter disk space threshold: 70\nAlert for &quot;\/dev\/sda3: Almost out of disk space 80% as on Thu May 11 01:54:50 AM EDT 2023<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"65_Create_a_New_User_and_Add_to_Sudo_Group\"><\/span>65. Create a New User and Add to Sudo Group<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can use the following script to create a new sudo user in your Linux system. The script will take the username and password as input to create the user. It will also create a home directory for the user besides adding the account to the sudo group:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter username: &quot; username\nread -p &quot;Enter password: &quot; password\nuseradd -m -s \/bin\/bash -p $(openssl passwd -1 $password) $username\nif [ $? -eq 0 ]; then\n  usermod -a -G sudo $username\n  mkdir \/home\/$username\/mydir\n  chown -R $username:$username \/home\/$username\/mydir\n  usermod -d \/home\/$username\/mydir $username\n  echo &quot;$username ALL=(ALL) NOPASSWD:ALL&quot; &gt;&gt; \/etc\/sudoers\n  echo &quot;User $username created successfully!&quot;\n  echo &quot;User $username added to sudo group!&quot;\nelse\n  echo &quot;Error while creating user!&quot;\nfi<\/code><\/pre>\n<p><strong>Syntax to run the Script: <\/strong><code class=\"\" data-line=\"\">sudo bash bin\/adv_example38.sh <\/code><\/p>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter username: Jim\nEnter password: linuxsimply\nUser Jim created successfully!\nUser Jim added to sudo group!<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"66_Monitor_Network_Traffic\"><\/span>66. Monitor Network Traffic<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following script monitors the receiving (RX) and transmitting(TX) packets over a network. User needs to enter the interface name that they want to monitor. Then every 10 seconds it will display the total packet received and transmitted and their size in KB:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter network interface to monitor traffic (ex. eth0): &quot; net\nwhile true\ndo\n  rx=$(ifconfig $net | grep &quot;RX packets&quot; | awk &#039;{print $3 $6 $7}&#039;)\n  tx=$(ifconfig $net | grep &quot;TX packets&quot; | awk &#039;{print $3 $6 $7}&#039;)\n  echo &quot;$(date) RX: $rx, TX: $tx&quot;\n  sleep 10\ndone<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter network interface to monitor traffic (ex. eth0): ens33\nWed May 10 16:55:40 +06 2023 RX: 342(40.4KB), TX: 171(18.4KB)\nWed May 10 16:55:51 +06 2023 RX: 355(41.6KB), TX: 178(19.0KB)\nWed May 10 16:56:01 +06 2023 RX: 361(42.0KB), TX: 178(19.0KB)\nWed May 10 16:56:11 +06 2023 RX: 361(42.0KB), TX: 178(19.0KB)<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"67_Monitor_CPU_and_Memory_Usage\"><\/span>67. Monitor CPU and Memory Usage<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script below can be used to monitor the CPU and Memory usage of a system. It extracts the CPU and Memory usage information every 10 seconds and converts them into a percentage for displaying on the screen:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nwhile true\ndo\n  cpu=$(top -bn1 | grep &quot;Cpu(s)&quot; | sed &quot;s\/.*, *\\([0-9.]*\\)%* \nid.*\/\\1\/&quot; | awk &#039;{print 100 - $1&quot;%&quot;}&#039;)\n  mem=$(free -m | awk &#039;NR==2{printf &quot;%.2f%%&quot;, $3*100\/$2 }&#039;)\n  echo &quot;$(date) CPU Usage: $cpu, Memory Usage: $mem&quot;\n  sleep 10\ndone<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Sun May\u00a0 7 02:19:49 AM EDT 2023 CPU Usage: 29.4%, Memory Usage: 68.78%\nSun May\u00a0 7 02:19:59 AM EDT 2023 CPU Usage: 7.1%, Memory Usage: 68.78%\nSun May\u00a0 7 02:20:10 AM EDT 2023 CPU Usage: 25%, Memory Usage: 68.72%\nSun May\u00a0 7 02:20:20 AM EDT 2023 CPU Usage: 17.6%, Memory Usage: 68.72%\nSun May\u00a0 7 02:20:30 AM EDT 2023 CPU Usage: 6.2%, Memory Usage: 68.70%<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"68_Creating_a_Script_and_Adding_It_to_PATH\"><\/span>68. Creating a Script and Adding It to PATH<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You can use the script below to customize another script and make it runnable. The script here will take another script name and the commands to write within this new script as user inputs. After receiving the input values, it will update the permission modes of the desired script and add it to the <strong>$PATH <\/strong>variable to make the new script runnable. After creation, you can run this new script with the <strong>bash <\/strong>keyword:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nread -p &quot;Enter a name for the command: &quot; my_comm\necho &quot;Enter commands to write on script:&quot;\nread comm\nread -p &quot;Enter path to the directory containing the command: &quot; comm_path\n# Create script for custom command\necho &quot;#!\/bin\/bash&quot; &gt; $my_comm.sh\necho &quot;$comm&quot; &gt;&gt; $my_comm.sh\n# Make script executable\nchmod +x $my_comm.sh\n# Add script to PATH\nexport PATH=&quot;$PATH$comm_path\/$my_comm.sh&quot;\necho &quot;A script called $my_comm has been created.&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter a name for the command: echo_hello\nEnter commands to write on script:\necho &quot;Hello from custom command!!&quot;\nEnter path to the directory containing the command: \/home\/susmit\/bin\nA script called echo_hello has been created.<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"69_Running_a_Command_at_Regular_Intervals\"><\/span>69. Running a Command at Regular Intervals<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script given below runs a command at a regular time interval. To achieve this task the user has to enter the desired command and the interval for running that command. The interval passed as input must be in the following format: <code class=\"\" data-line=\"\">m h dom mon dow<\/code><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nread -p &quot;Enter command to run: &quot; com\ncommand_to_run=$(which $com)\nread -p &quot;Enter interval for running the command (m h dom mon dow): &quot; interval\n# Add command to crontab\n(crontab -l ; echo &quot;$interval $command_to_run&quot;) | sort - | uniq - | crontab -\necho &quot;Command added to crontab and will run at $interval&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter command to run: echo &quot;1 Minute passed!&quot; &gt;&gt; time.log\nEnter interval for running the command (m h dom mon dow): * * * * *\nCommand added to crontab and will run at * * * * *<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"70_Downloading_Files_from_a_List_of_URLs\"><\/span>70. Downloading Files from a List of URLs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The following script takes a filename as input where a list of URLs should be stored. The script will iterate through the list of URLs and download the available contents on the link. It displays each download information on the terminal along with the \u201cCompleted Download\u201d message. Upon downloading files from all the URLs, it shows another message saying \u201cAll files downloaded successfully!\u201d:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\nread -p &quot;Enter the filename containing URLs: &quot; url_file\nwhile read -r url; do\n  filename=$(basename &quot;$url&quot;)\n  curl -o &quot;$filename&quot; &quot;$url&quot;\n  echo &quot;Completed Download $filename&quot;\n  done &lt; &quot;$url_file&quot;\n  echo &quot;--------------------------------------------------------------------------------------------&quot;\n  echo &quot;All files downloaded successfully!&quot;\ndone<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter the filename containing URLs: urls.txt\n% Total\u00a0\u00a0\u00a0 % Received % Xferd\u00a0 Average Speed\u00a0\u00a0 Time\u00a0\u00a0\u00a0 Time\u00a0\u00a0\u00a0\u00a0 Time\u00a0 Current\nDload\u00a0 Upload\u00a0\u00a0 Total\u00a0\u00a0 Spent\u00a0\u00a0\u00a0 Left\u00a0 Speed\n0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0 0 --:--:-- --:--:-- --:--:--\u00a0\u00a0\u00a0\u00a0 0curl: (6) Could not resolve host: linuxsimply.com\nCompleted Download Emacs-Keybindings-or-Shortcuts-in-Linux.pdf\ncurl: (3) URL using bad\/illegal format or missing URL\nDownloaded\n% Total\u00a0\u00a0\u00a0 % Received % Xferd\u00a0 Average Speed\u00a0\u00a0 Time\u00a0\u00a0\u00a0 Time\u00a0\u00a0\u00a0\u00a0 Time\u00a0 Current\nDload\u00a0 Upload\u00a0\u00a0 Total\u00a0\u00a0 Spent\u00a0\u00a0\u00a0 Left\u00a0 Speed\n0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0 0 --:--:-- --:--:-- --:--:--\u00a0\u00a0\u00a0\u00a0 0curl: (6) Could not resolve host: linuxsimply.com\nCompleted Download Bash-Terminal-Keyboard-Shortcuts-for-Information.pdf\n--------------------------------------------------------------------------------------------\nAll files downloaded successfully!<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"71_Organize_Files_in_a_Directory_Based_on_Their_File_Types\"><\/span>71. Organize Files in a Directory Based on Their File Types<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The script given below organizes files in a directory depending on their type. The user needs to give a destination directory path to organize the files along with the source directory path.<\/p>\n<p style=\"text-align: justify;\">This script will create five directories: 1) Documents, 2) Images, 3) Music, 4) Videos, and 5) Others only if they do not already exist on the destination path. Then, it will check all the files and their extension and move them to the corresponding directory. If there is any unknown file extension, then the script will move the file to the Others Directory:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n# Specify the source and destination directories\nread -p &quot;Enter path to the source directory: &quot; source_dir\nread -p &quot;Enter path to the destination directory: &quot; dest_dir\n# Create the destination directories if they don&#039;t exist\nmkdir -p &quot;${dest_dir}\/Documents&quot;\nmkdir -p &quot;${dest_dir}\/Images&quot;\nmkdir -p &quot;${dest_dir}\/Music&quot;\nmkdir -p &quot;${dest_dir}\/Videos&quot;\nmkdir -p &quot;${dest_dir}\/Others&quot;\n#Move files to the appropriate directories based on their extensions\nfor file in &quot;${source_dir}&quot;\/*; do\n  if [ -f &quot;${file}&quot; ]; then\n    extension=&quot;${file##*.}&quot;\n    case &quot;${extension}&quot; in\n    txt|pdf|doc|docx|odt|rtf)\n    mv &quot;${file}&quot; &quot;${dest_dir}\/Documents&quot;\n    ;;\n    jpg|jpeg|png|gif|bmp)\n    mv &quot;${file}&quot; &quot;${dest_dir}\/Images&quot;\n    ;;\n    mp3|wav|ogg|flac)\n    mv &quot;${file}&quot; &quot;${dest_dir}\/Music&quot;\n    ;;\n    mp4|avi|wmv|mkv|mov)\n    mv &quot;${file}&quot; &quot;${dest_dir}\/Videos&quot;\n    ;;\n    *)\n    mv &quot;${file}&quot; &quot;${dest_dir}\/Others&quot;\n    ;;\n    esac\n  fi\ndone\necho &quot;Files organized successfully!&quot;<\/code><\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">Enter path to the source directory: \/home\/susmit\/Downloads\nEnter path to the destination directory: \/home\/susmit\/Downloads_Organized\nFiles organized successfully!<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">From complex task automation to efficient data manipulation, you now possess the ability to tackle real-world challenges with confidence. Embrace the power of advanced shell scripting and unlock a world of automation and efficiency.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"People_Also_Ask\"><\/span>People Also Ask<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"What_are_the_practical_uses_of_shell_scripting\"><\/span>What are the practical uses of shell scripting?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Some practical uses of shell scripting are automating repetitive system tasks, such as scheduling file backups, system resources monitoring, and user account management. Utilizing different commands in bash script enables us to increase productivity accuracy and automate complex tasks.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Which_shell_scripting_language_is_the_most_popular_and_why\"><\/span>Which shell scripting language is the most popular and why?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><strong>B<\/strong>ourne <strong>A<\/strong>gain <strong>SH<\/strong>ell (BASH) is the most popular shell used in the Linux Operating System. The BASH can also be installed on Windows OS.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Can_we_compile_shell_script\"><\/span>Can we compile shell script?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><strong>Yes,<\/strong> we can compile shell scripts. The SHC (Shell Script Compiler) converts shell scripts to executable binaries and encodes and decrypts them. This binary conversion protects the shell scripts from accidental changes and source code modification.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_1_in_shell_script\"><\/span>What is $1 in shell script?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">In shell script, $1 means the first command line argument passed to the script or function. For example, if you want to pass argument1 to the script.sh, simply execute .\/script.sh argument1 on the terminal. Then, within the script, \u2018$1\u2019 represents the value of argument1. Similarly, \u2018$2\u2019, \u2018$3\u2019 would represent the second and third arguments, respectively.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_the_difference_between_shell_script_and_bash_script\"><\/span>What is the difference between shell script and bash script?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The main difference between shell script and bash script is that shell script is written to be executed by any shell, while bash script is specifically written to be executed by the shell shell. Shell script is compatible with multiple shells, but Bash script is incompatible with other shells. A shell script may not utilize Bash-specific features, but a Bash script utilizes Bash-specific features and enhancements.<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [{\n    \"@type\": \"Question\",\n    \"name\": \"What are the practical uses of shell scripting?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"Some practical uses of shell scripting are automating repetitive system tasks, such as scheduling file backups, system resources monitoring, and user account management. Utilizing different commands into bash script enables us to increase productivity accuracy and automate complex tasks.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"Which shell scripting language is the most popular and why?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"Bourne Again SHell (BASH) is the most popular shell used in Linux Operating System. The BASH can also be installed on Windows OS.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"Can we compile shell script?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"Yes, we can compile shell scripts. The SHC (Shell Script Compiler) converts shell scripts to executable binaries and encodes and decrypts them. This binary conversion protects the shell scripts from accidental changes and source code modification.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What is $1 in shell script?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"In shell script, $1 means the first command line argument passed to the script or function. For example, if you want to pass argument1 to the script.sh, simply execute .\/script.sh argument1 on the terminal. Then, within the script, \u2018$1\u2019 represents the value of argument1. Similarly, \u2018$2\u2019, \u2018$3\u2019 would represent the second and third arguments, respectively.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What is the difference between shell script and Bash script?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"The main difference between shell script and bash script is that shell script is written to be executed by any shell, while bash script is specifically written to be executed by the shell shell. Shell script is compatible with multiple shells, but Bash script is incompatible with other shells. A shell script may not utilize Bash-specific features, but a Bash script utilizes Bash-specific features and enhancements.\"\n    }\n  }]\n}\n<\/script><\/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;38274&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;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;Advanced Shell Script With Examples [Free Downloads]&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&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-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            <span class=\"kksr-muted\">Rate this post<\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bash Scripting offers the concepts of string, array, and loops for achieving advanced programming goals. In this article, I will &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Advanced Shell Script With Examples [Free Downloads]\" class=\"read-more button\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#more-38274\" aria-label=\"Read more about Advanced Shell Script With Examples [Free Downloads]\">Read more<\/a><\/p>\n","protected":false},"author":314894,"featured_media":38423,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[95],"class_list":["post-38274","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash-programming","tag-bash-scripting-examples","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Advanced Shell Script With Examples [Free Downloads] - LinuxSimply<\/title>\n<meta name=\"description\" content=\"Advanced shell script examples offers the concepts of string, array, and loops that will elevate your shell scripting skills.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Advanced Shell Script With Examples [Free Downloads] - LinuxSimply\" \/>\n<meta property=\"og:description\" content=\"Advanced shell script examples offers the concepts of string, array, and loops that will elevate your shell scripting skills.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxSimply\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/dasgupta.susmit\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-13T03:01:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-13T08:01:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/Advanced_Shell_Script_With_Examples.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Susmit Das Gupta\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Susmit Das Gupta\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/\"},\"author\":{\"name\":\"Susmit Das Gupta\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/38abbef9a1053d9faec8935dc39f10fa\"},\"headline\":\"Advanced Shell Script With Examples [Free Downloads]\",\"datePublished\":\"2024-03-13T03:01:08+00:00\",\"dateModified\":\"2024-03-13T08:01:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/\"},\"wordCount\":3557,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Advanced_Shell_Script_With_Examples.png\",\"keywords\":[\"bash scripting examples\"],\"articleSection\":[\"Bash Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/\",\"name\":\"Advanced Shell Script With Examples [Free Downloads] - LinuxSimply\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Advanced_Shell_Script_With_Examples.png\",\"datePublished\":\"2024-03-13T03:01:08+00:00\",\"dateModified\":\"2024-03-13T08:01:14+00:00\",\"description\":\"Advanced shell script examples offers the concepts of string, array, and loops that will elevate your shell scripting skills.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Advanced_Shell_Script_With_Examples.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Advanced_Shell_Script_With_Examples.png\",\"width\":400,\"height\":400,\"caption\":\"Advanced shell script examples.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/advanced-shell-script-examples\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Advanced Shell Script With Examples [Free Downloads]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"name\":\"LinuxSimply\",\"description\":\"All About Linux\",\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/linuxsimply.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\",\"name\":\"LinuxSimply\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"width\":355,\"height\":48,\"caption\":\"LinuxSimply\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/38abbef9a1053d9faec8935dc39f10fa\",\"name\":\"Susmit Das Gupta\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Susmit-Das-Gupta-II-96x96.png\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Susmit-Das-Gupta-II-96x96.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Susmit-Das-Gupta-II-96x96.png\",\"caption\":\"Susmit Das Gupta\"},\"description\":\"Hello everyone. I am Susmit Das Gupta, currently working as a Linux Content Developer Executive at SOFTEKO. I am a Mechanical Engineering graduate from Bangladesh University of Engineering and Technology. Besides my routine works, I find interest in going through new things, exploring new places, and capturing landscapes. Read Full Bio\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/dasgupta.susmit\",\"https:\\\/\\\/www.instagram.com\\\/susmit_dasgupta\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/susmitdasgupta\\\/\"],\"url\":\"https:\\\/\\\/linuxsimply.com\\\/author\\\/susmit\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Advanced Shell Script With Examples [Free Downloads] - LinuxSimply","description":"Advanced shell script examples offers the concepts of string, array, and loops that will elevate your shell scripting skills.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/","og_locale":"en_US","og_type":"article","og_title":"Advanced Shell Script With Examples [Free Downloads] - LinuxSimply","og_description":"Advanced shell script examples offers the concepts of string, array, and loops that will elevate your shell scripting skills.","og_url":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/","og_site_name":"LinuxSimply","article_author":"https:\/\/www.facebook.com\/dasgupta.susmit","article_published_time":"2024-03-13T03:01:08+00:00","article_modified_time":"2024-03-13T08:01:14+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/Advanced_Shell_Script_With_Examples.png","type":"image\/png"}],"author":"Susmit Das Gupta","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Susmit Das Gupta","Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#article","isPartOf":{"@id":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/"},"author":{"name":"Susmit Das Gupta","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/38abbef9a1053d9faec8935dc39f10fa"},"headline":"Advanced Shell Script With Examples [Free Downloads]","datePublished":"2024-03-13T03:01:08+00:00","dateModified":"2024-03-13T08:01:14+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/"},"wordCount":3557,"commentCount":0,"publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"image":{"@id":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/Advanced_Shell_Script_With_Examples.png","keywords":["bash scripting examples"],"articleSection":["Bash Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/","url":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/","name":"Advanced Shell Script With Examples [Free Downloads] - LinuxSimply","isPartOf":{"@id":"https:\/\/linuxsimply.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#primaryimage"},"image":{"@id":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/Advanced_Shell_Script_With_Examples.png","datePublished":"2024-03-13T03:01:08+00:00","dateModified":"2024-03-13T08:01:14+00:00","description":"Advanced shell script examples offers the concepts of string, array, and loops that will elevate your shell scripting skills.","breadcrumb":{"@id":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxsimply.com\/advanced-shell-script-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#primaryimage","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/Advanced_Shell_Script_With_Examples.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/03\/Advanced_Shell_Script_With_Examples.png","width":400,"height":400,"caption":"Advanced shell script examples."},{"@type":"BreadcrumbList","@id":"https:\/\/linuxsimply.com\/advanced-shell-script-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxsimply.com\/"},{"@type":"ListItem","position":2,"name":"Advanced Shell Script With Examples [Free Downloads]"}]},{"@type":"WebSite","@id":"https:\/\/linuxsimply.com\/#website","url":"https:\/\/linuxsimply.com\/","name":"LinuxSimply","description":"All About Linux","publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxsimply.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/linuxsimply.com\/#organization","name":"LinuxSimply","url":"https:\/\/linuxsimply.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","width":355,"height":48,"caption":"LinuxSimply"},"image":{"@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/38abbef9a1053d9faec8935dc39f10fa","name":"Susmit Das Gupta","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Susmit-Das-Gupta-II-96x96.png","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Susmit-Das-Gupta-II-96x96.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Susmit-Das-Gupta-II-96x96.png","caption":"Susmit Das Gupta"},"description":"Hello everyone. I am Susmit Das Gupta, currently working as a Linux Content Developer Executive at SOFTEKO. I am a Mechanical Engineering graduate from Bangladesh University of Engineering and Technology. Besides my routine works, I find interest in going through new things, exploring new places, and capturing landscapes. Read Full Bio","sameAs":["https:\/\/www.facebook.com\/dasgupta.susmit","https:\/\/www.instagram.com\/susmit_dasgupta\/","https:\/\/www.linkedin.com\/in\/susmitdasgupta\/"],"url":"https:\/\/linuxsimply.com\/author\/susmit\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/38274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/users\/314894"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/comments?post=38274"}],"version-history":[{"count":0,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/38274\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media\/38423"}],"wp:attachment":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media?parent=38274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/categories?post=38274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/tags?post=38274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}