{"id":32557708,"url":"https://github.com/ad1w/bash-doc","last_synced_at":"2026-05-18T14:36:56.057Z","repository":{"id":302661560,"uuid":"1013192115","full_name":"ad1w/bash-doc","owner":"ad1w","description":"some tips on bash shell. Just a personal documentation","archived":false,"fork":false,"pushed_at":"2025-08-01T14:23:00.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-28T23:39:16.019Z","etag":null,"topics":["bash","bash-script","shell","shell-script"],"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/ad1w.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,"zenodo":null}},"created_at":"2025-07-03T13:53:45.000Z","updated_at":"2025-08-01T14:23:04.000Z","dependencies_parsed_at":"2025-08-01T16:30:53.586Z","dependency_job_id":"22e4ec71-5768-4527-9ec1-8c466a18ede4","html_url":"https://github.com/ad1w/bash-doc","commit_stats":null,"previous_names":["ad1w/bash-tips","ad1w/bash-doc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ad1w/bash-doc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad1w%2Fbash-doc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad1w%2Fbash-doc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad1w%2Fbash-doc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad1w%2Fbash-doc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ad1w","download_url":"https://codeload.github.com/ad1w/bash-doc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ad1w%2Fbash-doc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33181314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"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","bash-script","shell","shell-script"],"created_at":"2025-10-28T23:37:03.560Z","updated_at":"2026-05-18T14:36:56.049Z","avatar_url":"https://github.com/ad1w.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# BASH tips\nSome tips on bash shell. Just a personal documentation\n\n## Remove  character\n```\nsed 's/character //'\n```\nfor example:\n```\n~ $ cat text.txt\nCantarel Bold 14\n\nto get \"Cantarel 14\" you can use:\n~ $ cat text.txt | sed 's/Bold //'\nCantarel 14\n```\n\n## Get character separated by something\n```\ncut -d 'something' -f column\n```\nfor example:\n```\n~ $ cat text.txt\ngtk-font-name=Cantarel, 14\n\nto get \"Cantarel, 14\" you can use:\n~ $ cat text.txt | cut -d '=' -f 2\nCantarel, 14\n```\n\n## Get characters on a specific line\n```\nawk 'NR==linenumber'\n```\nfor example:\n```\n~ $ cat text.txt\nABCD\nEFGH\nIJKL\n\nto get \"EFGH\" you can use:\n~ $ cat text.txt | awk 'NR==2'\nEFGH\n```\n\n## Get characters on a specific column\n```\nawk '{print $numbercolumn}'\n```\nfor example:\n```\n~ $ cat text.txt\nABCD EFGH IJKL\n\nto get \"EFGH\" you can use:\n~ $ cat text.txt | awk '{print $2}'\nEFGH\n```\n\n## Add file or directory on bash script\n```\nexport PATH=\"${PATH}:/location\"\n```\nfor example:\nyou want to add some files on your ```script``` directory, you can add this line in your bash script\n```\n#!/bin/bash\nexport PATH=\"${PATH}:/script\"\n```\n\n## Print character on bash script\n```\n#!/bin/bash\ncat \u003c\u003cEOF\ncharacter\nEOF\n```\nfor example, you can create a new file ```text.txt``` then you add this line:\n```\n#!/bin/bash\ncat \u003c\u003cEOF\nHello World\nEOF\n```\nthen if you run, the result will be:\n```\n~ $ bash text.txt\nHello World\n```\n\n## Add the colors\n```\ntput setaf \u003c0-15\u003e\n```\nfor example, you can create a new file ```text.txt``` then you add this line:\n```\n#!/bin/bash\n# Add colors\n#normal\nbla=$(tput setaf 0)\nred=$(tput setaf 1)\ngre=$(tput setaf 2)\nyel=$(tput setaf 3)\nblu=$(tput setaf 4)\nmag=$(tput setaf 5)\ncya=$(tput setaf 6)\nwhi=$(tput setaf 7)\n#bright\nbbla=$(tput setaf 8)\nbred=$(tput setaf 9)\nbgre=$(tput setaf 10)\nbyel=$(tput setaf 11)\nbblu=$(tput setaf 12)\nbmag=$(tput setaf 13)\nbcya=$(tput setaf 14)\nbwhi=$(tput setaf 15)\n\n# Print result\ncat \u003c\u003cEOF\n$redHello World\nEOF\n```\nthen if you run, the result will be:\n```\n~ $ bash text.txt\nHello World (with red color)\n```\n\n## Add value option on bash\n```\nif [[ $1 = \"value\" ]]; then\n  action\nelse\n  action\nfi\n```\nfor example, in your ```text.txt``` you can add this line:\n```\n#!/bin/bash\nval_1=Hello World\nval_2=Hello There\n\nif [[ $1 = \"-1\" ]]; then\n  echo \"$(val_1)\"\nelse\n  echo \"$(val_2)\"\nfi\n```\nthen if you run with \"-1\", the result will be:\n```\n~ $ bash text.txt -1\nHello World\n```\nif you run without \"-1\", the result will be:\n```\n~ $ bash text.txt\nHello There\n```\n\n## Add value option (number) on bash\n```\nif [[ $1 =~ ^[0-9]+$ ]]; then\n  action\nelse\n  action\nfi\n```\nfor example, in your ```text.txt``` you can add this line:\n```\n#!/bin/bash\n\nif [[ $1 =~ ^[0-9]+$ ]]; then\n  echo \"the value is\" $1\nelse\n  echo \"the value is -\"  \nfi\n```\nthen if you run with \"number\", the result will be:\n```\n~ $ bash text.txt 9379\nthe value is 9379\n```\nif you run with \"character\", the result will be:\n```\n~ $ bash text.txt abcd\nthe value is -\n```\n\n## Arithmetic operations\n```\neq=$(($1+$2))\necho $1 + $2 = $eq\n```\nfor example, in your ```test.txt``` you can add this line:\n```\n#!/bin/bash\n\neq=$(($1+$2))\necho $1 + $2 = $eq\n```\nthen if you run, the result will be:\n```\n~ $ bash test.txt 10 7\n10 + 7 = 17\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fad1w%2Fbash-doc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fad1w%2Fbash-doc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fad1w%2Fbash-doc/lists"}