(I cannot just use file command, please look at sample runs) Write a shell scrip
ID: 3631148 • Letter: #
Question
(I cannot just use file command, please look at sample runs)Write a shell script called filetype.bash that accepts either
a filename or a directory name. Then, your script should display
its type on the screen.
A sample run of the script will be like below:
$ ./filetype
Usage: filetype file_or_dir.
This is another sample run.
$ ./filetype /etc
/etc is a directory.
This is another sample run.
$ ./filetype /etc/passwd
/etc/passwd is a file.
This is another sample run.
$ ./filetype /dev/audio
/dev/audio is neither a file nor a directory.
Explanation / Answer
echo "Enter any file name or file path" read file ls -l $file ------------------------------------------------------------------- output ------------------------------------------------------------------- Enter any file name or file path cut -rw-r--r-- 1 mca258 502 0 Sep 22 15:53 cut
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.