Write Shell Script Named Filesizesh Takes Name Directory Within Current Working Directory Q37163300

Write a shell script named filesize.sh that takes the name of adirectory within the current working directory as a command-lineargument and prints the name and size of each file to standardoutput. You may assume there are no sub directories within thegiven directory.

Example output:

$ ./filesize.sh FILES

/FILES/examplefile1.txt

120916

/FILES/examplefile2.pyd

8393


Answer


dirs=$1
if [ -z $dirs ]
then
   echo “usage: ./filesize.sh <directoryname>”
else
   du -ah $dirs
fi

ubuntu17 (fresh) [Running)- Oracle VM VirtualBox File Machine View Input Devices Help Activities Terminal Mon 01:51 madhav@ma

if you have any doubt then please ask me without any hesitationin the comment section below , if you like my answer then

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.