Bash scripts

Change upper case to lower case

#echo ‘TEST’|/usr/bin/tr -s ‘[:upper:]’ ‘[:lower:]’
test

Work with array

IFS=$’\n’ ##here tells how to devide the output, default is space
##but I want to put each line into a array
files=($(ls ./) ##put file names into an array using ()
for (( i=0;i<${#files[@]};i++ ));do mv $files[$i] $files[$i]_OLD done

Match pattern

if [[ $string =~ “data” ]];do
echo “$string contains data”
done

Leave a Reply

Your email address will not be published.