When you want to run a command in Bash that does nothing then you can make use of the colon command (:). It is also called a null command.
Example:
$ :
$
As you can see when I just ran the : command it executed successfully and the bash prompt was returned.
To show that the command was a success, let us add some logic.
$ : && echo "The command was successful" || echo "The command failed"
The command was successful
Why would one use "do nothing" command?
The "do nothing" command is mostly useful in bash scripts, where you have a requirement to satisfy the requirement of having a command as a placeholder that allows the script to continue executing without performing any specific action.
Script Example:
#!/bin/bash
echo "Some logic before doing nothing..."
:
echo "Some logic after doing nothing..."

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!