for j in *.20071231* .ctl .dat
do
(
if [ -f "$j" && "$j" -ne "C*20071231.log" ] then
cp "$base/*." "$base1"
fi
)
done
My requirement is for all files that has extension *.20071231* *.ctl *.dat
should be copied to another folder.
But those with caaa.20071231.log should'nt be copied.
Jhon:
could u please explain me the code which u gave.
if [ -f "$j" ]; then
case $j in
C*20071231*.log) ;; // I am confuesed here as there is no opening brace here ) // What is the purpose of this brace here cp "$base/*." "$base1" ;;
esac
fi
So, you are correct in seeing only a ) and wondering where the matching ( character is. It simply is not needed.
If a match on pattern-1, then commands-1 is executed, and so on. The *) means that if none of the above were matched, do commands.