Elektrine lite

← Feed

@ajlewis2@social.vivaldi.net

Post #444885

2026-02-21 17:30 UTC

@stefano Do you have any advice on learning programming in bash? Did you learn in a course or a book or some other way? I've just spent a couple weeks with a book on Perl and have decided that since I'm more familiar with bash, it might be better to learn a bit of it.

Replies (8)

  • @stefano@mastodon.bsd.cafe 2026-02-21 18:14

    @ajlewis2 I've started with it 30 years ago, no books. Just experience. One step after another. Maybe there are better - and more effective - ways. But now, I search for specific things online and re-elaborate them. So, unfortunately, I don't think I can recommend something - or, at least, something specific. But I'll boost your post, hoping the Fediverse will come with some suggestions

    Open ##1248211

  • @teajaygrey@snac.bsd.cafe 2026-02-21 20:49

    Chiming in with a: if you like books, maybe you can find some old O'Reilly books on ksh/Korn Shell that would be modestly helpful? I guess O'Reilly doesn't publish physical books anymore, which is jaw dropping to me, but probably means you can find such things on the used market for not much money! I realized, you asked about bash specifically, and ksh is not bash, but: There are a plethora of UNIX shells and it's helpful to be versed in more than one! I'm an outlier insomuch as I got habituated to tcsh long ago and still prefer it over most other choices (csh and tcsh users seem to be very fringe), even if I end up using zsh a lot these days. CC: @stefano@bsd.cafe

    Open ##1248221

  • @jordan1111@mastodon.sdf.org 2026-02-21 20:55

    @ajlewis2 @stefano Really depends on your goals I think. Programming what exactly? As an aside I love how you call it bash "programming" (which I guess is accurate) because then I can actually call myself a programmer 😃 I need some fundamental knowledge in OOP because I always get lost trying to learn C or anything like it.

    Open ##1248222

  • @andi@snac.sonnenmulde.at 2026-02-22 08:48

    There's a book for Bash on Linux for free online. https://linuxcommand.org/tlcl.php I know, its's not BSD but most things should still be the same. As long as one does not touch system stuff. CC: @stefano@bsd.cafe

    Open ##1248225

  • @wauz@mastodon.de 2026-02-22 14:00

    @ajlewis2 Hmm. Maybe, you search for scripts in general and build a collection. Then you read scripts related to your task and get some inspirations... I once learned BASIC by transfering PASCAL-code into it. @stefano

    Open ##1248227

  • @AFresh1@bsd.network 2026-02-22 15:45

    @ajlewis2 @stefano i didn't spot it in the replies, but https://www.shellcheck.net/ is so helpful. A local version is probabaly available in your favorite package repository. Not only do the errors tell you how to fix it, the wiki has in depth descriptions of why. Like any tool it is sometimes wrong (usually when you _want_ token splitting IME) but it helps so much.

    Open ##1248230

  • @FLOX_advocate@floss.social 2026-02-24 04:16

    @ajlewis2 @stefano I learned on the command line many moons ago I really learned bash when I taught shell scripting at a community college ABSG is a package in debian, maybe other distros abs-guide - The Advanced Bash-Scripting Guide You could try command wrappers, e.g. if you use rsync put it in a file, then figure out how to use command line arguments BTW, $RANDOM gives you a random number between 0 and 3276 every time you use it, but don't assign to it or the magic breaks have fun!

    Open ##1248232

  • @harmoniousanger@zeroes.ca 2026-02-26 07:35

    @ajlewis2 @stefano The Bash Guide. A labour of love from lhunath & greycat https://mywiki.wooledge.org/BashGuide - also available as PDF. If you're familiar with IRC, join irc.libera.chat#bash and idle a few days, noting the factoids greybot spits out. It's written for beginners, yes, but I learned more from TBG than from five years of sysadmin work - and it made my job easier.

    Open ##1248237