Write a bash script that takes a directory as an argument Th

Write a bash script that takes a directory as an argument. This script then touches every file in the given directory, and prints as output (to the console) the name, word-count, and file size (in bytes) of every file in the directory.

Solution

note:some of commands used in unix

wc word count

wc -w word count

wc -c byte count

echo printing operation on screen

cat allows us to create single or multiple files, view contain of these file, concatenate and redirect their output in terminal or some other file

dir=$1

#takes directoryh as an argument

for file in $dir/* ;

do

#touch every file

touch $f

#print names to console with wordcount and fie size
echo -n \"$file \"
cat $file | wc -w -c
done

Write a bash script that takes a directory as an argument. This script then touches every file in the given directory, and prints as output (to the console) the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site