In: Computer Science
Please write a shell script called "myfilechecking" to determine whether a file belongs to one of the following categories:
The screenshot of the script:
The screenshot of the execution of the script:
can you please paste the script code? Thank you
Note : As mentioned in question when we use script with a.out it should give output as "a.out is an executable file." But It will show "a.out is a script file" because in linux system it is showing as readable also as shown below
[vishalh@param-demo openmp-codes]$ ls -al a.out |
#!/bin/sh
if [ ! -e $1 ]; then
echo "$1 does not exits."
else
if [ -d $1 ]; then
echo "$1 is a directory."
fi
if [ -r $1 -a -x $1 -a ! -d $1 ]; then
echo "$1 is a script file."
fi
if [ ! -r $1 -a -x $1 -a ! -d $1 ]; then
echo "$1 is a executable file."
fi
if [ -r $1 -a ! -d $1 -a ! -x $1 ]; then
echo "$1 is a reular ascii file."
fi
fi