How to create bash script that loops on all subdirectories then from subdirectory checks…
Private research annotation
Sign in to add a private research label or note.
- User
How to create bash script that loops on all subdirectories then from subdirectory checks is file contains phase "I'm a teapot". If contains then move file outside of subdirectory and rename it with prefix "_CONTAINS_"?
- Assistant
You can create a bash script with the following code to achieve this:
bash#!/bin/bash # Loop through all subdirectories for dir in */; do echo "Checking files in directory $dir" # Loop through all files in subdirectory for file in "$dir"*; do # Check if file contains "I'm a teapot" string if grep -q "I'm a teapot" "$file"; then echo "File $file contains 'I'm a teapot'" # Move file outside of subdirectory and rename it with prefix "_CONTAINS_" mv "$file" "$(dirname "$file")/_CONTAINS_$(basename "$file")" fi done doneExplanation:
for dir in */; doloops through all subdirectories.
- User
Can you create configuration for haproxy with email notification if error occur for scenario: frontend will work on port 80 and 8080. Backend will cover 4 servers: 10.0.0.1, 10.0.0.2, 10.0.0.3, 10.0.0.4 all works with port 81. Please be sure haproxy will check if backend servers are working.
- Assistant
Sure, here's an example configuration for HAProxy that meets your requirements:
- User
please continue
- Assistant
Sorry about that, I accidentally hit send before I was finished. Here's the rest of the configuration:
sql