Tag archives for scripting - Page 2
Check if array contains value in shell script
Check if array contains value in shell script Here is simple bash script to check if array contains value . We can iterate over array and check if value is…
How to get process ID of background process?
I usually prefer to execute process in background so that we don't need to worry if terminal got killed due to timeout or accidently. However, what if you want to…
Loop through business day and previous business day in shell
Shell script loop to execute some task for business day and previous business day. If previous business day is weekend then script should skip the weekend date and pick Friday…
How to Split String with a Delimiter in Shell Script
Split String with a Delimiter in Shell Script You can use Internal Field Separator (IFS) variable in shell script to split string into array. When we set IFS variable then…
How to validate date format in shell script
How to validate date format in shell script There are multiple ways you can validate date format in shell script. You can compare date format with regular expression or you…
How to define multiline string variable in shell?
How to define multiline string variable in shell? In your bash/shell scripting experience you may face scenario where you need to define multi line string variable. Here is multiple ways…
How to Run a Shell Script in Infinite Loop
You can run a shell script in infinite loop by using while loop. #!/bin/bash while true do echo "Press CTRL+C to stop the script execution" # Enter your desired command in…
Deleting Lines Containing Specific string from multiple files
Deleting Lines Containing Specific string from multiple files Deleting Lines Containing Specific string from multiple files recursively Syntax: grep -Rl "STRING" /directory/path/ | xargs sed -i "/STRING/d" Example: Below example…