Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

. Write a program named check_directory.sh to examine a given directory’s conten

ID: 3800589 • Letter: #

Question

. Write a program named check_directory.sh to examine a given directory’s contents.

run “./check_dir.sh path”

checks if each item in the path directory is a file or a directory.

outputs the number of files and number of directories in specified path directory.





2. Write a program named check_source_cp.sh to copy files. When run

Run “./check_source_cp.sh sourcefile targetfilename”,

checks whether source file exists.

If source file exists, the copy sourcefile to targetfilename.

If source file does not exist, exit program with an error message “Source file does not exist signed <script writer name (your name)!>”.

my name is Richard Okpala must be done using linux


Explanation / Answer

There are two solutions that I can think of -

2. Check whether source file exists

#!/bin/bash
source = $1
target = $2
if [-f $source]; then
cp $source $target
else
   echo "Source file does not exist <Manan Shah>"
fi

Save and execute the script -----

chmod +x check_source_cp.sh
./check_source_cp.sh path/some/source/ path/some/target