r/devops • u/Nedko_Hristov • Dec 04 '22
Searching for a good bash course to improve my scripting skills
It can be a book or video course it whatever. My only requirement is to be a complete guide ( not post for solving a specific problem).
Thanks.
70
Upvotes
27
u/xiongchiamiov Site Reliability Engineer Dec 04 '22
http://mywiki.wooledge.org/BashPitfalls is not a guide per se, but it's important reading for anyone doing shell scripting. Also read the separate page on Quotes.
23
u/nullpackets Dec 04 '22
Installing shell check really helped me pick up the finer details mistakes I kept making, it's a linter for bash and helps you grow out of old habits with contextual help
https://www.shellcheck.net/
10
u/Thwonp Dec 04 '22
exercism.org has a good bash track
9
u/futurecomputer3000 Dec 04 '22
Best thing is just to start imo. Do something cool with your machine.
5
u/ManFrontSinger Dec 04 '22
The Linux Command Line - No Starch Press
I forget the author. You can do the googling.
4
u/Romanmir Dec 04 '22
This is usually my go-to for bash scripting: https://tldp.org/LDP/abs/html/index.html
3
u/aishudio9 Dec 04 '22
Read this - https://www.ossblog.org/wp-content/uploads/2017/06/Linux_shell_scripting_v2.pdf
3
u/Atik Dec 04 '22
There's also a video course from Learn Linux TV: Bash Scripting on Linux
2
u/samrocketman Dec 04 '22
I highly recommend reading the bash man page. You can convert it to PDF using a simple command like this man2pdf.
Some examples of things you'll learn:
{}which is unlike other programming languages.testor[is actually a program (which [) and also a shell builtin. Because it is a program, it takes space separated arguments. Coming from other programming languages people treatif [ ... ]; thenthe same asif(...) {but once you understand it is a program it becomes easier to remember the syntax.I plan to write a blog post but I've been kind of sitting on it for a few years.
2
u/x-talk Dec 04 '22
This helped me the most: https://www.gnu.org/software/bash/manual/bash.html
2
u/izalac Dec 05 '22
As someone who is self-taught, if you want to learn it fast, the best advice I could give you is - dive into it fully. If you're currently not running Linux, run it on real hardware - as a dual boot, on an old laptop, whatever, and use it as your main computer for as much as you can. Do your workflows in it. Use command line tools as much as possible.
Experiment with standard linux commands, pipes, input, output - that's bread and butter of bash. Note some parallels, e.g. between vim commands and sed parameters. Learn at least some basics of awk so you can use it in your pipelines. Play with cron, tar, openssh, systemd, and mail transfer agents such as exim and postfix. Reformat some logs.
The knowledge of what you can do with Linux's command line tools and how to string them together is the most important part of being effective in bash. You get that knowledge far quicker when you're fully immersed in the OS running it. Maybe try installing Arch Linux (on real hardware or VM) in the classic, wiki way as a practice to get more comfortable in shell.
Knowing some other scripting solutions, such as Python or Ansible will also help you determine when to use bash, and when to use something else.
2
u/whetu Dec 04 '22
With all due respect given to this sub, /r/bash is the better place to look/ask. This thread from 6 days ago is relevant to your interests
1
u/tomasbondok Dec 04 '22
https://exercism.org/
-2
u/Petelah Dec 04 '22
Anytime you want to write something generic in some programming language write it in a bash script.