this post was submitted on 30 Apr 2025
4 points (83.3% liked)
Bash
931 readers
1 users here now
Talk about the Bash Shell and Bash scripting
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Some stylistic notes
head -1
syntax is obsolete in POSIX, replaced byhead -n 1
.for filename in $(ls)
will break on whitespace and is inefficient. You can use shell globbing for this instead, e.g.,for filename in *
./tmp/ dir
, I believe it will remove/tmp
anddir
)Saved my bacon with this comment. Fixed a ton of (seemingly) innocuous errors.
100% use shellcheck! Saves so much time. Even better: https://github.com/bash-lsp/bash-language-server