The following shell script is used to process files in direc

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 teat

Solution

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

 The following shell script is used to process files in directory test while in current working directory. It has following features: Add a prefix \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site