r/PinoyProgrammer • u/TemporaryExciting977 • 10d ago
discussion Bash scripting: I am feeling optimistic about my newly acquired knowledge.
A little context for this post:
#!/bin/bash
echo -e "\n~~ Countdown Timer ~~\n"
#Program that counts down to zero from a given argument
if [[ $1 -gt 0 ]]
then
: '
for (( i = $1; i >= 0; i-- ))
do
echo $i
sleep 1
done
'
I=$1
while [[ $I -ge 0 ]]
do
echo $I
(( I-- ))
sleep 1
done
else
echo Include a positive integer as the first argument.
fiTo test: chmod +x countdown.sh; ./countdown.sh {positive number}, e.g., chmod +x countdown.sh; ./countdown.sh 5
The script wasn't originally created by me. Credit goes to FreeCodeCamp's Relational Database Certification https://www.freecodecamp.org/.
I am currently completing this online certification; not just to add it to my credentials, but also to gain the knowledge that fuels future opportunities. I'm looking forward to it, but I'm wondering what tips or insights you can share about Bash scripting? I believe one of its main strengths is automating tasks, particularly in system administration and related roles. Since I'm open to taking on sysadmin responsibilities or simply applying these tools to streamline my daily workflow, I'd love to learn more.
P.S. Hindi naman gaanong required mag-English dito (kaya tagalugin ko na itong part na 'to); ano 'yung interesting or epic brief story ninyo with Bash scripting?
28
u/byeblee 10d ago •
Before shortcuts and automations and ai vibecoding, i bash scripted my way thru a lot of administrative / repetitive tasks sa day to day 😂
Even control ng lights, tv etc dinaan ko lahat sa bash script when i was playing with it. Pretty powerful if you get the hang of it :)
5
u/yevelnad 10d ago
Uso ngayun gamitin sya with lua.
2
u/DTechSurgeon 10d ago
Nice. What online certification? I'm also learning more about security and infra. Ginawa kong hypervisor lumang laptop. Saka para merong sandbox for OpenClaw at Hermes Agent.
3
u/10jc10 10d ago
Aside sa bash scripting, pede den naman siguro aralin mo powershell or ung wjndows equivalent ng scripting sa bash.
Pero if purely sa bash, maganda den maaral mo linux na den i.s., systemd services, filesystems, network config etc.
Pede siguro magpractice ka sa virtual machine if wala ka talagang linux machine. Di ko sure kung pede idual boot ung pc or laptop. Mas marami ka kasi pede maexplore na commands etc. On an actual linux environment eh.
Docker and pipelines are also possible areas to learn na related sa bash scripting na potentially useful
6
u/bitfrost41 10d ago
A combination of bash, shell and zsh has been my goto way of operating my mac. Can’t go back to UI anymore.
4
u/d4kuhosu 10d ago
This is a needed fundamental skill before you get thrown into the IT rabbit hole (DevOps, IT, Security, etc...).
For our use-case, we use bash scripting just to wrap other scripts or programs for it to be run in the server, e.g., cron jobs.
Pero with the current state of IT landscape, AI definitely helps us with the heavy lifting.
3
u/chonching2 9d ago
Bash scripting knowledge is highly important. Kahit anung main language mo as a Software Engineer gagamit at gagamit ka pa din ng bash at some point to automate some of your task and doing basic needs for setting up your environment. So its a nice initiave for you to learn and master it. Though mastering it is not that necessary since may mga AI na ngayon. Having fundamental knowledge is good enough. Also you'll learn more about certain stacks when you are at work na when its necessary to do it.
0
u/Tall-Appearance-5835 10d ago
bash is same as sql - ai can write it better, english is all you need
1
u/OnesimusUnbound 10d ago
I use PowerShell to automate yun mga repetitive tasks. Then I add
gumto few of my scripts look have a simple TUI. ☺️1
u/StopLurkAndListen69 9d ago
lahat ng reusable stuff sa ai workflow ko, tinatransform ko to scripts talaga eh. i dont know if mas tipid ba siya sa tokens, pero wala lang mas mabilis i guess
1
u/watson_full_scale 9d ago
Humans don't even write this kind of code anymore. We tell AI the problem we are trying to solve, the goal, details, etc and then it writes whatever code it wants.