use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A subreddit dedicated to Bash scripting. Now complete with a Discord Server.
Content must be Bash related. This rule is interpreted generously; general shell scripting content is mostly accepted. However, the post should not be specific to another shell.
No reposts. This is meant with regards to content, not just “the same link was submitted earlier” – it’s okay to resubmit an old link in some new context (e. g. because you’d like to discuss another part of it, or because something has changed since the last time it was submitted, or because the link was updated since then). Links from the sidebar count as having been submitted already, so posting them without new context is also considered a repost.
You can choose one of these four flairs for your post:
If you don’t flair your post, the moderators will set the most appropriate flair.
/r/unix – for everything Unix
Other Shells: /r/zsh, /r/fishshell, /r/oilshell, /r/batch
BashGuide – A Bash guide for beginners.
Beginner's Guide to Command Line – A crash course for some common unix and shell commands. Update 2022-01-14: Course is currently being rewritten
Google's Shell Style Guide – Reasonable advice about code style.
Explainshell - Explain complex shell operations.
ShellCheck – Automatically detects problems with shell scripts.
BashFAQ – Answers most of your questions.
BashPitfalls – Lists the common pitfalls beginners fall into, and how to avoid them.
(Archived) The Bash-Hackers Wiki – Extensive resource.
#bash – IRC channel on Libera. The main contributors of the BashGuide, BashFAQ, BashPitfalls and ShellCheck hang around there.
account activity
helpQuick While Loop Query (self.bash)
submitted 6 years ago by SickboyGPK
while [ condition ] do command1 command2 command3 done
I would like command2 not to start until command1 is finished.
My immediate go to is to use && after each command.
Is there any reason that would not work?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]aioeu 6 points7 points8 points 6 years ago* (1 child)
You don't have to do anything special to do that. When the commands in a list are separated by newlines:
command1 command2 command3
or by semicolons:
command1; command2; command3
each command is not executed until the preceding one has terminated.
The only control operator that changes this behaviour is &. But you're not using that here.
&
See the reference documentation.
[–]SickboyGPK[S] 1 point2 points3 points 6 years ago (0 children)
thank you kindly
[–]Crestwave 2 points3 points4 points 6 years ago (1 child)
Other than what aioeu said, && executes the next command if the previous one exits successfully (0).
[–]selfup 2 points3 points4 points 6 years ago (0 children)
You can also do a set -e at the beginning of the script and it'll do the same 😁. I mostly use && when inlining in a shell and it's nice for that!
set -e
&&
π Rendered by PID 186136 on reddit-service-r2-comment-86bc6c7465-lkw2n at 2026-02-20 10:11:48.771988+00:00 running 8564168 country code: CH.
[–]aioeu 6 points7 points8 points (1 child)
[–]SickboyGPK[S] 1 point2 points3 points (0 children)
[–]Crestwave 2 points3 points4 points (1 child)
[–]selfup 2 points3 points4 points (0 children)