Linux BASH Scripting

Bash Colors

You can make your BASH script more pretty, by colorizing its output.

Use ANSI escape sequences to set text properties like foreground and background colors.

HowTo : Check If a String Exists

Sometimes, we need to check if the pattern presents in a file and take some actions depending on the result.

It can be done with the help of 'exit status codes'. Each Linux command returns a status when it terminates normally or abnormally

You can use command exit status in the shell script to display an error message or perform some sort of action.

HowTo : Check If a File Exists

While creating BASH Scripts, it is commonly helpful to check if a file exists before attempting to perform some action.

This is a job for test command (the same as []). This command allows you to do various tests, and sets its 'exit code' to 0 (TRUE) or 1 (FALSE), whenever a test succeeds or not.

HowTo : Read a file Line By Line

If you need to read each line from a file and perform some action with it, then you can use 'while' loop.