Write a program named checkdirectorysh to examine a given d

. 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


Solution

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

. 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 fil

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site