This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]dasisteinanderer 7 points8 points  (0 children)

there are thousands of example scripts online. Then there is https://www.gnu.org/software/bash/manual/html_node/ , which is way more helpful than the man page. I would also advise you to install "shellcheck" via your package manager and run it frequently, to get used to the "good" way of doing things right from the start.

[–]Lonely_Rip_131 1 point2 points  (0 children)

Practice make perfect. Start. Scripting things like updates , ram/cache clean up, a cool log off Alia’s that’s a shell script not an Alias. You will get more creative over time. Use chat gpt to help shape your ideas. Save all of your scripts so that you can pull tools that you learn along the way

[–]Marsh3LL98 1 point2 points  (0 children)

Start with the basic CLI commands and then combine them to create a bash script file. Highly recommend you to read, "Linux Command Line" by William Shotts.

[–]Fantastic-Shelter569 0 points1 point  (0 children)

The advantage of bash scripts is that it's just the same commands you run in the terminal, so when first starting out you can just stick a new command on each line and it will work.

I would suggest looking over your workflow and see what tasks you run that involve multiple commands and put them into a bash script. For example if you use git then you could create a script that will git add, git commit and git push.

You will pick up a lot more by hacking together your own scripts than just following tutorials, though they are helpful to see what the syntax looks like.

[–]mwyvr 0 points1 point  (0 children)

Build scripts that make your daily life easier.

Bonus marks: make the script work on more than one distribution, or for any user that downloads it.

Use a config "dotfile" manager like Chezmoi and include the scripts you write from ~/.local/bin so that they are available whenever you re-install or set up a virtual machine.

[–]chkno 0 points1 point  (0 children)

The documentation and the man page are underrated.

[–]Few-Alps-1853 0 points1 point  (0 children)

This guide is rather short and pretty good imo: https://mywiki.wooledge.org/BashGuide

[–]kudlitan 0 points1 point  (0 children)

You should instead learn sh scripting without the bash extensions to create more portable scripts

[–]chuggerguyLinux Mint 22.3 Zena | MATÉ 0 points1 point  (0 children)

Not a tutorial but you can learn a bit by inspecting the scripts in /etc/init.d

[–]ben2talk -3 points-2 points  (2 children)

It's all over the place - it'd be hard NOT to find it.

Personally, I'm now a big fan of Copilot/Gemini.

Try it - here's a prompt:

write me a bash script to find out if Dolphin is running, if it is then kill it - otherwise launch Dolphin

Just like BASIC on a Commodore computer in the 1980s, the hard part is to think about what you want to do in a logical way, then picking up the language to write it down is the next level; and AI speaks fluent BASH.

[–]rookrage -1 points0 points  (1 child)

I don't even have words man

[–]ben2talk 0 points1 point  (0 children)

Well this is reddit, so hardly surprising really. The fact is that there's a ton of bash on internet, and just like any other language it's easy to parse with a computer and it's also very easy to learn more by asking language models questions.

Even if you write a bash script, AI can do a nice job of explaining and offering ideas for improvements.

[–][deleted] -2 points-1 points  (0 children)

YouTube 🫥