Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. [10 points] Write a BASH script fc. sh that counts files inside a given directory. fc. sh should take either zero or one argument
2. [10 points] Write a BASH script fc. sh that counts files inside a given directory. fc. sh should take either zero or one argument only. If provided, the argument should be a legal path to a directory. If no argument is given, the script should count the files in the current directory. Note: The script should not operate recursively, i.e. it is not supposed to count files inside (sub)directories found in the directory being explored. Also, hidden files should not be counted. The script should conform to the output shown in Listing 4; it should print messages (in square brackets) about directories not being found, the argument not being a directory, and the PWD being used. Observe how it also lists the number of files in a directory by following the symbolic link to it. Listing 4: File count script interaction on Polaris 2 $ fc.sh dir2 final ans: 2 \$fc.sh /1ib/ final ans: 2 $fs./lib/algs4.jarstdlib.jar $ fc.sh /1ib/ final ans: 2 Note: If the argument provided is not a legal directory, the script should exit with code 1. If an incorrect number of arguments is provided, the script should exit with code 2. In readme. txt, paste the following commands and the results of running them on Polaris: 1. fc.sh /etc 2. fc.sh/usr/bin/ 3. fc.sh /11b 4. fc.sh temp 2359823 Deliverable: fc. sh, readme. txt
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started