The break Statement The break statement allows you to exit the current loop. It is often used in an if statement that is contained within a while loop, with the condition in the while loop always evaluating to true. This is useful if the number of times the loop is executed depends on input from […]
Archives for July 2020
How to use until loop in Shell Scripts
The until Loop The until loop is very similar to the while loop, except that the until loop executes as long as the command fails. After the command succeeds, the loop exits and execution of the script continues with the statement following the done statement. The syntax for the until loop is: until control_command do […]
“while” Loop Examples in Shell Scripts
The while loop allows you to repeatedly execute a group of statements while a command executes successfully. The syntax for the while loop is: while control_command do statement1 … statementN done where, control_command can be any command that exits with a success or failure status. The statements in the body of the while loop can […]
chattr Command Examples to Change File Attributes (Make files immutable)
Files can also have attributes that are expressed in another way than the permissions we have seen so far. An example of this is making a file immutable (a fancy word, which means it cannot be changed). An immutable file still has normal ownership and group and RWX permissions, but it will not allow the […]