linux:bash

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:bash [2026/01/10 14:49] – [Control Operators] mhlinux:bash [2026/01/11 11:57] (current) – [Control Operators] mh
Line 121: Line 121:
 This means: This means:
  
-Try something +Try something, but if it errors (exit code ≠ 0):  
-If it errors: +  silence the error message (send to ''/dev/null'') 
-silence the error message +  immediately run ''true'' ( || operator passes along to second part) 
-immediately run ''true'' +  Overall ''exit'' status becomes success (exit code = 0)
-Overall ''exit'' status becomes success+
  
 In plain English: In plain English:
Line 143: Line 142:
 It’s about acknowledging expected non-problems. It’s about acknowledging expected non-problems.
  
 +----
 +
 +=== && AND Operator ===
 +
 +This control operator tells bash to run a second command **only if the first command before it succeeded**.
 +
 +If the first command fails, the second command is entirely skipped.
 +
 +**Example**
 +<code bash>
 +$ rm hello.txt && echo "Deleted file."
 +rm: cannot remove 'hello.txt': No such file or directory
 +</code>
 +
 +Because the file did not exist, the ''echo'' command was not run.
 ===== Arguments ===== ===== Arguments =====
  
  • linux/bash.1768052966.txt.gz
  • Last modified: 2026/01/10 14:49
  • by mh