{"id":25724509,"url":"https://github.com/deroyace/shell-scripting","last_synced_at":"2026-05-05T14:31:35.249Z","repository":{"id":130559640,"uuid":"500531816","full_name":"DeRoyace/Shell-Scripting","owner":"DeRoyace","description":"This repo is for learning Shell Programming","archived":false,"fork":false,"pushed_at":"2022-12-20T18:13:48.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-18T14:38:01.482Z","etag":null,"topics":["bash-script","linux","programming","shell-scripting","shell-scripts","unix-shell"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DeRoyace.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"License","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-06-06T17:34:25.000Z","updated_at":"2022-11-10T15:55:53.000Z","dependencies_parsed_at":"2023-07-07T10:16:36.805Z","dependency_job_id":null,"html_url":"https://github.com/DeRoyace/Shell-Scripting","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DeRoyace/Shell-Scripting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeRoyace%2FShell-Scripting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeRoyace%2FShell-Scripting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeRoyace%2FShell-Scripting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeRoyace%2FShell-Scripting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeRoyace","download_url":"https://codeload.github.com/DeRoyace/Shell-Scripting/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeRoyace%2FShell-Scripting/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32653465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","programming","shell-scripting","shell-scripts","unix-shell"],"created_at":"2025-02-25T21:47:26.569Z","updated_at":"2026-05-05T14:31:35.244Z","avatar_url":"https://github.com/DeRoyace.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shell Programming\nIt is a set of instructions or commands that communicates with the Operating System via commands. We can do the same thing using terminal, but that makes it time consuming for dealing with commands that are used repeatedly. So we make use of shell programs to make a full bunch of instructions or commands that are top be used multiple times on several files.\n\n## Creating a shell script file\nEvery shell script file has ```.sh``` extension.\n\nWe can create files using various commands like: ```cat``` ```touch``` ```nano``` ```vi``` ```vim``` ```nvim``` etc.\n```sh\n$ vi filename.sh\n```\nAfter the above command, the **_vi_** editor opens up in the terminal. By default the editor is in **command mode** i.e, ghere keys will be the command. Thus we cannot write anything in the editor now. Wen need to press ```i``` key or ```INSERT``` key to make it in **INSERT mode**. Now we can write our program.\nTo know the usage of the editor see this link [Vim editor usage](https://github.com/DeRoyace/Vim-editor-usage/blob/master/vimBasics.txt) [vi and vim editor usage is same]\n\n## Running a Shell Program\nWe can run a shell program by using ```sh``` command\n```sh\n$ sh filename.sh\n```\nWe can also run the program like this ```./filename.sh```\n\n## I/O using shell scripts\n For display something in the terminal, we use ```echo``` command. An example is shown below:\n```sh\n$ echo \"Hello world!\"\nHello world!\n```\nFor taking inputs from the user, ```read``` command is used. See the script below:\n```sh\necho \"Enter a number: \"\nread num\necho \"Your number is $num\"\n```\n\u003e ### Output:\n\u003e```sh\n\u003eEnter a number: \n\u003e97\n\u003eYour number is 97\n\u003e```\n\n## Comments\nThese are lines which are not to be read by the compiler or the interpreter. These lines are simply ignored.\nIn Shell scripts, we write comments using ```#``` symbol at the very first of the comment line.\n```sh\n# this is a comment\necho \"This is not a comment\"  # another comment\n```\n\n## Conditional Operators\n* -lt : less than\n* -gt : greater than\n* -eq : equals to\n* -ne : not equal to\n* -le : less than or equal to\n* -ge : greater than or equal to\n\u003e ### Usage:\n```sh\n# Finding the larger number between two numbers:\nnum1=30\nnum2=25\nif [ $num1 -lt $num2 ]\nthen\n    echo \"$num2 is larger\"\nelse\n    echo \"$num1 is larger\"\nfi\n```\n\n## References\n- [Linux-cmds | DeRoyace](https://github.com/DeRoyace/Linux-cmds)\n- [Vim-editor-usage](https://github.com/DeRoyace/Vim-editor-usage/blob/master/vimBasics.txt)\n- [GNU Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_node/index.html#SEC_Contents)\n- [13.3 Understanding Shell Scripts -  O'Reilly](https://www.oreilly.com/openbook/debian/book/ch13_03.html)\n- [Shell Scripting for Beginners – How to Write Bash Scripts in Linux | freecodecamp](https://www.freecodecamp.org/news/shell-scripting-crash-course-how-to-write-bash-scripts-in-linux/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderoyace%2Fshell-scripting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderoyace%2Fshell-scripting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderoyace%2Fshell-scripting/lists"}