r/PinoyProgrammer • u/TemporaryExciting977 • 17d 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?
5
u/yevelnad 17d ago
Uso ngayun gamitin sya with lua.
3
u/TemporaryExciting977 17d ago
Work na work na ako e, nang mapakinabangan ko naman itong mga newly acquired knowledge na ito. Hayyy, anyway. I'll take note of that.
2
u/DTechSurgeon 17d ago
1
u/TemporaryExciting977 17d ago
freecodecamp.com yung ginagamit ko, relational databases certification yung kinukuha ko. Ang very interesting dito ay hindi lang siya exclusive sa SQL (since relational databases), kundi included din sa lessons yung bash, shell, at terminal scripting. So, it was fun to learn kasi nakita ko rin agad yung advantage na matuto rin ako nun (SKL). Feeling ko, available din do'n yung gusto mong aralin.
3
u/10jc10 17d 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
1
u/TemporaryExciting977 17d ago
I agree, depende pa rin naman sa use-case minsan. Good thing ay may passion and I'm into pen testing hehe, feel ko lang (applicable yung context ng bash scripting sa pen testing/cybersecurity field).
2
u/10jc10 17d ago
First encounter ko with bash scripting is training sa nilipatan kong company. After non ayun tuloy tuloy na at nagamit ko den sya for a lot of things na inaaral at tintry out ko ngayon.
Coming from a totally different background (engineering pero ung specialty or specific area is different), di ko aakalain na kelangan malipat pa ko ngayon work para matutunan ko sya. No choice na kase din siguro kasi un ung requirement sa new work ko unlike sa old work ko na pwede ako magchoose ng ibang gagawin so naiiwasan ko.
2
u/byeblee 17d ago
Pwede yan dual boot, partition lang ng hdd tas isang section is reserved for linux. Ubuntu is fine kung nag aaral palang sa bash.
Kung gusto mo maging ultra nerdy overlord (na actually useful din) install ka ng non-gui ubuntu. Terminal lang agad pag bukas mo, mapipilitan ka matuto at mahalin yung commands ng terminal dahil walang ibang choice hahaha.
Ganyan ko sya inapproach aralin nung nasa college pa ko
2
6
u/bitfrost41 17d 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 17d 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 17d 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 17d ago
bash is same as sql - ai can write it better, english is all you need
2
u/TemporaryExciting977 17d ago
But still, it doesn't make sense kung AI lang yung marunong, tapos ako, nganga.
2
u/catterpie90 17d ago
Yes, dapat marunong ka pa rin to check the AI's work. Mas mabilis pa rin talagang mag review ng work kesa gumawa from scratch.
0
1
u/feedmesomedata Moderator 17d ago •
![]()
Bash and SQL are too basic that if you don't know it or have a hard time understanding it then no sense staying in the industry.
Those two are like knowing how to walk or speak, ganun sya ka-basic. Yes, one can use AI to come up with complex scripts to not waste time but not knowing how to write it just doesn't make sense if you want to be called a programmer.
1
u/OnesimusUnbound 17d ago
I use PowerShell to automate yun mga repetitive tasks. Then I add gum to few of my scripts look have a simple TUI. ☺️
1
u/StopLurkAndListen69 16d 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 16d 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.

28
u/byeblee 17d 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 :)