- loop file with pattern
lines=$(find "$logdir" -name '*.log' -print)
while read line
do
echo "processing \"$line\""
done <<< "$(echo -e "$lines")"
- get abspath, dirpath and basename
abspath="$(cd "$(dirname "$file")" && pwd)/$(basename "$file")"
dirpath=$(dirname "$abspath")
basename=$(basename "$abspath" ".log")
- check substring
string='My long string'
if [[ $string == *"My long"* ]]; then
echo "It's there!"
fi
- bold
bold=$(tput bold)
normal=$(tput sgr0)
echo "${bold}This is bold {normal} and back to normal"