The following shell script is used to process files in directory test while in c
ID: 3936511 • Letter: T
Question
The following shell script is used to process files in directory test while in current working directory. It has following features: Add a prefix "my" to all c files m directory test Rename test as my test Add an extension "bak" to all txt files in directory test E g Rename test, txt as test txt bak Compile all java files in directory test Count the number of c files m directory test bin/bash ncfile=0 for dir in do case "Sdir" in *-c) *.txt) esac done echo there are Sncfile C files in directory teatExplanation / Answer
nCfile= 0
for dir in *; do
case "$dir" in
*.c)nCfile=$((nCfile+1))
mv "$dir" "my$dir"
;;
*.txt)mv "$dir" "$dir.bak"
;;
*.java)javac "$dir"
;;
esac
done
echo $nCfile