{"id":23141571,"url":"https://github.com/harshitsahu2311/shell-scripting","last_synced_at":"2025-10-27T18:12:39.796Z","repository":{"id":265061492,"uuid":"895011369","full_name":"harshitsahu2311/Shell-Scripting","owner":"harshitsahu2311","description":"Shell scripting involves creating a script (a text file) with a series of Linux/Unix commands, executed by the shell (the command-line interface of an OS). The most common shell is bash, but there are others like sh, zsh, and fish.","archived":false,"fork":false,"pushed_at":"2024-11-27T17:33:53.000Z","size":3230,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T21:16:25.222Z","etag":null,"topics":["bash-script","linux","shell-script"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harshitsahu2311.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-27T11:59:52.000Z","updated_at":"2024-11-27T17:33:58.000Z","dependencies_parsed_at":"2024-11-27T14:45:25.508Z","dependency_job_id":null,"html_url":"https://github.com/harshitsahu2311/Shell-Scripting","commit_stats":null,"previous_names":["harshitsahu2311/shell-scripting"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshitsahu2311%2FShell-Scripting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshitsahu2311%2FShell-Scripting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshitsahu2311%2FShell-Scripting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshitsahu2311%2FShell-Scripting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harshitsahu2311","download_url":"https://codeload.github.com/harshitsahu2311/Shell-Scripting/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166594,"owners_count":20894744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash-script","linux","shell-script"],"created_at":"2024-12-17T14:13:58.344Z","updated_at":"2025-10-27T18:12:34.752Z","avatar_url":"https://github.com/harshitsahu2311.png","language":"Shell","readme":"# Shell-Scripting 🐧\n![logo](https://github.com/harshitsahu2311/Shell-Scripting/blob/main/shell.gif)\nShell scripting involves creating a script (a text file) with a series of Linux/Unix commands, executed by the shell (the command-line interface of an OS). The most common shell is bash, but there are others like sh, zsh, and fish.\n\n## Why is Shell Scripting Important for DevOps?\nDevOps is all about automating repetitive processes to speed up the development cycle, improve collaboration, and ensure more reliable software delivery. Shell scripting plays a critical role in automating these tasks and creating seamless workflows.\u003cbr/\u003e\nIn DevOps, shell scripts are incredibly useful for:\n\n- Automating tasks like setting up environments, deploying applications, and running tests.\n\n- Configuring systems such as servers, databases, or cloud environments.\n\n- Managing large systems by performing tasks across multiple servers at once.\n\n## Variables\nA shell variable is a character string in a shell that stores some value. It could be an integer, filename, string, or some shell command itself. Basically, it is a pointer to the actual data stored in memory. We have a few rules that have to be followed while writing variables in the script (which will be discussed in the article). Overall knowing the shell variable scripting leads us to write strong and good shell scripts.\n```\n#!/bin/bash\n\n# This is Jetha Lal ki Duniya\n\n\u003c\u003c comment\nAnything \nwritten \nhere will not be execute\ncomment\n\n'\nThis is also an method of multi-line comment\n'\n\nname=\"babitaji\" # variable declaration\n\necho \"Name is $name, and date is $(date)\" # here variable is allocated and command `date` is runned \n\necho \"enter the name:\"\n\nread username # user input\n\necho \"You entered $username\"\n\n```\nTo run any script - \u003cbr/\u003e\n` chmod +x script.sh` \u003cbr/\u003e\n`./script.sh` or `bash script.sh`\n\nOutput: \n\n`Name is babitaji, and date is wed Nov 24 05:38:34 UTC 2024 ` \u003cbr/\u003e\n`enter the name:` \u003cbr/\u003e\nKunal\u003cbr/\u003e\n`You entered Kunal\n`\u003cbr/\u003e\n\n## Arguments\nCommand-line arguments are passed in the positional way i.e. in the same way how they are given in the program execution. \n```\n# Arguments\n'\n./varibles.sh harshit sahu 34\n      $0        $1     $2  $3    \n'\n#!/bin/bash\n\n# This is Jetha Lal ki Duniya\n\nname=\"babitaji\"\n\necho \"Name is $name, and date is $(date)\"\n\necho \"enter the name:\"\n\nread username\n\necho \"You entered $username\"\n\necho \"The characters in $0 are:  $1 $2\" # example of arguments\n\n```\nOutput:\n\n```/arguments.sh harshit sahu``` \u003cbr/\u003e\n\n`Name is babitaji, and date is wed Nov 24 05:38:34 UTC 2024` \u003cbr/\u003e\n`enter the name:` \u003cbr/\u003e \nMaster \u003cbr/\u003e\n`You entered Master` \u003cbr/\u003e\n`The characters in ./aruguments.sh are: harshit sahu` \u003cbr/\u003e\n\n## Create User Script\n```\n#!/bin/bash\n\nread -p \"Enter username: \" username # p stands for prompt \n\necho \"you entered $username\"\n\nsudo useradd -m $username\n\necho \"New User added\"\n\n```\nOutput:\n`Enter username:` Harshit \u003cbr/\u003e\n`you entered Harshit`\u003cbr/\u003e\n`New User added` \u003cbr/\u003e\n\nCheck by this command:\n`cat /etc/passwd`\n\n## If Else Elif\n```\n#!/bin/bash\n\nread -p \"Jetha ne mud ke kise dekha: \" bandi\nread -p \"Jetha ka pyaar %: \" pyaar\n\nif [[ $bandi == \"daya bhabhi\"  ]]; # start of if statemet\nthen\n\techo \"Jetha is loyal\"\nelif [[ $pyaar -ge 100 ]];\nthen\n\techo \"Jetha is loyal\"\nelse\n\techo \"Jetha is not loyal\"\nfi  # end of if statement\n\n```\nOutput:\n\n`./if-else.sh` \u003cbr/\u003e\n`Jetha ne mud ke kise dekha:` babitaji \u003cbr/\u003e\n`Jetha ka pyaar %:` 110 \u003cbr/\u003e\n`Jetha is loyal`\n\n## For loop\n```\n#!/bin/bash\n\n# This is for loops script which creates folder with passed arg 1 as name and arg2 as starting range to arg3 as ending range\n\n\u003c\u003c comment\n 1 is argument 1 which is folder name\n 2 is start range\n 3 is end rangeask\ncomment\n\nfor (( num=$2 ; num\u003c=$3; num++ ))\ndo\n\tmkdir \"$1$num\"\ndone\n\n```\nOutput: \n`./for_loop.sh Harshit 1 5` \u003cbr/\u003e\n`ls` \u003cbr/\u003e\n`Harshit1 Harshit2 Harshit3 Harshit4 Harshit5` \u003cbr/\u003e\n\nIf you want to delete \u003cbr/\u003e\n`rm -r Har*`\n## While loop\n```\n#!/bin/bash\n\nnum=0\n\nwhile [[ $num -le 10  ]]\ndo\n\techo $num\n\tnum=$((num+2))\ndone\n```\n\nOutput:\n`0 \n2\n4\n6\n8\n10\n`\n## Functiona\n```\n#!/bin/bash\n\n\u003c\u003c disclaimer\nThis is just for infotainment purpose\ndisclaimer\n\n# This is function definition\n\nfunction is_loyal() {\nread -p \"$1 ne mud ke kise dekha: \" bandi\nread -p \"$1 ka pyaar %\" pyaar\n\nif [[ $bandi == \"daya bhabhi\"  ]];\nthen\n\techo \"$1 is loyal\"\nelif [[ $pyaar -ge 100 ]];\nthen\n\techo \"$1 is loyal\"\nelse\n\techo \"$1 is not loyal\"\nfi\n}\n\n# This is function call\nis_loyal \"tom\"\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshitsahu2311%2Fshell-scripting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharshitsahu2311%2Fshell-scripting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshitsahu2311%2Fshell-scripting/lists"}