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. Colorizing Shell Use the following template for writing colored text: echo -e “\e[COLORmSample Text\e[0m” Option Description -e Enable interpretation of backslash escapes \e[ Begin the color modifications COLORm Color Code […]
bash
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 […]
Bash: Test If File Exists
While creating a bash script, it is commonly helpful to test if file exists before attempting to perform some action with it. This is a job for the test command, that allows to check if file exists and what type is it. As only the check is done – the test command sets the exit […]
Bash: Read File Line By Line – While Read Line Loop
The while loop is the best way to read a file line by line in Linux. If you need to read a file line by line and perform some action with each line – then you should use a while read line construction in Bash, as this is the most proper way to do the […]