HacksLinux SysAdmin Notes
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.
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.
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.
If you need to read each line from a file and perform some action with it, then you can use 'while' loop.
Copyright © 2011-2017 Shell Hacks - Linux Howtos and Tutorials