_ _ | |__ __ _ ___| |__ | '_ \ / _` / __| '_ \ | |_) | (_| \__ \ | | | |_.__/ \__,_|___/_| |_| GNU Bash is a command line shell for interactive use with GNU readline, as well as shell scripting. It's commonly used as the default login shell on GNU/Linux systems. Here's what people say about bash (and sh): It's too big and too slow. \~ bash(1) nobody really knows what the Bourne shell's grammar is. Even examination of the source code is little help. \~ Tom Duff's rc(1) paper This style guide is more a recognition of its use rather than a suggestion that it be used for widespread deployment. \~ Google's bash style guide The Bourne shell language is one of, perhaps the, least internally consistent programming language still widely used today. \~ user zwol on stack overflo $ printf "$(cat log.log | grep -e "$(date +%F\"\")" | grep -e e ror | sed -E "s/^ F.*$\n/${eth}|en[o,p]/g" | tr [:space:] '\n' sort | uniq -d) >> fuckshit.piss > >^C^C^C^C > > \~ someone somewhere right no + + + + + I end up writing a lot of bash. It's potent enough for scripting silly stuff like simple site generators, administration tools, curl wrappers... Throw in fzf(1) and your scripts get a decent interface too. It's fairly featured so scripts end up mostly self-contained, with little reliance on coreutils of various systems. Some patterns are fun to use too. Here, in sdf's gopherspace, anyone can use it for CGI scripts. There's no one real authorative source on how to write bash. This page will list some of the resources which helped me pick up and use bash, and maybe my write-ups on it's features if I ever dare commit some. + + + + + | |
The Linux Command Line by William Shotts | |
Not really a bash book, but it does walk you through bash scripti and various coreutils. It's how I learned the basics, so I though I should include it. | |
bash help command | |
It's understated how handy the builtin bash help is. Look at this stuff, these are great cheat sheets! | |
Bash Reference Manual | |
The bash manpage is (in)famously unreadable. Use this manual instead. Try the parameter expansion chapter for good shit. | |
Google Shell Style Guide | |
Style guides are used for keeping code readable and maintainable within communities, but also for noting best practices. Plenty of opinionated decisions in the doc, but also generally good ideas like indenting long pipelines. | |
pure bash bible | |
Collection of fancy bash tricks to replace external calls to coreutils and such. Generally, the less external calls, the more efficient the script. But bash's so slow anyway, it's more of a principle/portability/fun thing. | |
password-store.sh | |
They don't want you to know, but the famous pass(1) password manager is actually just a bash script, as are plenty of good CLI programs. While it's not exactly the code quality that makes pass amazing, this is a bash program people over the world trust their secrets with every day. Certainly worth inspecting. | |
shellcheck | |
Shellcheck is a linting tool for shell scripts - not just bash, but works just as well for it. Basically, it finds common errors and bad style, and suggests corrections, which you may learn from (or contest...). It's good at hunting bashisms in POSIX shell scripts too. You can call it on files from the command line, or integrate it into your editor. I use it inside kakoune. | |
Ghost in the Shell by vermaden | |
Series of articles on general shell usage, covers common UNIX magics as well as plain neat scripting and interactive use tricks + + + + + | |
Understanding ${0} | |
My notes on what's $0 and how to use it. + + + + + More to come when I bother. |