{"id":17941786,"url":"https://github.com/r0h1th-1dd4e2/linux-workshop","last_synced_at":"2025-04-03T13:19:59.148Z","repository":{"id":259145895,"uuid":"876432936","full_name":"R0h1th-1DD4E2/Linux-Workshop","owner":"R0h1th-1DD4E2","description":"Cheat Sheet for bash scripting","archived":false,"fork":false,"pushed_at":"2024-10-22T00:47:51.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T13:19:55.856Z","etag":null,"topics":["bash","bash-scripting","example","shebang","tutorial-code"],"latest_commit_sha":null,"homepage":"","language":null,"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/R0h1th-1DD4E2.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-10-22T00:45:31.000Z","updated_at":"2024-10-22T00:49:30.000Z","dependencies_parsed_at":"2024-10-23T01:18:52.001Z","dependency_job_id":null,"html_url":"https://github.com/R0h1th-1DD4E2/Linux-Workshop","commit_stats":null,"previous_names":["r0h1th-1dd4e2/linux-workshop"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R0h1th-1DD4E2%2FLinux-Workshop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R0h1th-1DD4E2%2FLinux-Workshop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R0h1th-1DD4E2%2FLinux-Workshop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R0h1th-1DD4E2%2FLinux-Workshop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/R0h1th-1DD4E2","download_url":"https://codeload.github.com/R0h1th-1DD4E2/Linux-Workshop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247006668,"owners_count":20868033,"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","bash-scripting","example","shebang","tutorial-code"],"created_at":"2024-10-29T02:04:11.010Z","updated_at":"2025-04-03T13:19:59.119Z","avatar_url":"https://github.com/R0h1th-1DD4E2.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"## Bash Scripting\n\n### Shebang\n`#!/bin/bash` - This tells the system that the script should be run with the bash shell.\n\n#### Example\n```bash\n#!/bin/bash\necho \"Hello, World!\"\n```\n\n### Variables in Bash\n```bash\n#!/bin/bash \nname=\"Alice\" \necho \"Hello, $name!\"\n```\n\n### User Input\n```bash\n#!/bin/bash\necho \"What's your name?\"\nread name\necho \"Hello, $name!\"\n```\n\n### Conditions (if statements)\n```bash\n#!/bin/bash\necho \"Enter a number:\"\nread num\n\nif [ $num -gt 10 ]; then\n  echo \"Your number is greater than 10!\"\nelse\n  echo \"Your number is 10 or less!\"\nfi\n```\n\n### Common Condition Tests:\n\n| Test                                     | Description                                  |\n| ---------------------------------------- | -------------------------------------------- |\n| `-d \u003cfile\u003e`                              | True if `\u003cfile\u003e` is a directory.             |\n| `-f \u003cfile\u003e`                              | True if `\u003cfile\u003e` is a regular file.          |\n| `-e \u003cfile\u003e`                              | True if `\u003cfile\u003e` exists.                     |\n| `-z \u003cstring\u003e`                            | True if `\u003cstring\u003e` is empty.                 |\n| `-n \u003cstring\u003e`                            | True if `\u003cstring\u003e` is not empty.             |\n| `\"\u003cstr1\u003e\" = \"\u003cstr2\u003e\"`                    | True if strings are equal.                   |\n| `\"\u003cstr1\u003e\" != \"\u003cstr2\u003e\"`                   | True if strings are not equal.               |\n| `-eq`, `-ne`, `-lt`, `-le`, `-gt`, `-ge` | Numeric comparisons.                         |\n| `!`                                      | Negates the condition (logical NOT).         |\n| `\u0026\u0026`                                     | Logical AND (both conditions must be true).  |\n| \\|\\|                                     | Logical OR (any one conditions can be true). |\n\n### Loops \n\n#### For Loop\n```bash\n#!/bin/bash\nfor i in {1..5}\ndo\n  echo \"Number: $i\"\ndone\n```\n\n#### While Loop\n```bash\n#!/bin/bash\ncounter=1\nwhile [ $counter -le 5 ]\ndo\n  echo \"Counter: $counter\"\n  ((counter++))\ndone\n```\n\n### Function\n```bash\n#!/bin/bash\n\ngreet() {\n  echo \"Hello, $1!\"\n}\n\ngreet \"Alice\"\ngreet \"Bob\"\n```\n\n### Comments\n```bash\n# This is a comment\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr0h1th-1dd4e2%2Flinux-workshop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr0h1th-1dd4e2%2Flinux-workshop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr0h1th-1dd4e2%2Flinux-workshop/lists"}