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

1) Create a Bash script which will take a single command line argument (a direct

ID: 3705286 • Letter: 1

Question

1) Create a Bash script which will take a single command line argument (a directory) and will print each entry in that directory. If the entry is a file it will print it's size. If the entry is a directory it will print how many items are in that directory.
2) Create a Bash script which will take 2 numbers as command line arguments. It will print to the screen the larger of the two numbers. 1) Create a Bash script which will take a single command line argument (a directory) and will print each entry in that directory. If the entry is a file it will print it's size. If the entry is a directory it will print how many items are in that directory.
2) Create a Bash script which will take 2 numbers as command line arguments. It will print to the screen the larger of the two numbers. 1) Create a Bash script which will take a single command line argument (a directory) and will print each entry in that directory. If the entry is a file it will print it's size. If the entry is a directory it will print how many items are in that directory.
2) Create a Bash script which will take 2 numbers as command line arguments. It will print to the screen the larger of the two numbers. 1) Create a Bash script which will take a single command line argument (a directory) and will print each entry in that directory. If the entry is a file it will print it's size. If the entry is a directory it will print how many items are in that directory.
2) Create a Bash script which will take 2 numbers as command line arguments. It will print to the screen the larger of the two numbers.

Explanation / Answer

Question 1:

#!/bin/bash

path=$1                                                                                                                                                              

echo 'File Path:'$path                                                                                                                                               

echo ' '                                                                                                                                                             

echo 'Entries in directories:'                                                                                                                                       

find ${path} | ls -l                                                                                                                                                 

echo ' '                                                                                                                                                             

echo 'No of Files:'                                                                                                                                                  

find ${path} ! -name . -printf '%y ' | sort | uniq -c | sed 's/f/regular files/;s/d/directory/;t'                                                                   

Question 2:

#!/bin/bash

first=$1                                                                                                                                                             

sec=$2

if [ $first -gt $sec ] ; then                                                                                                                                        

echo -e " $first is greatest number "                                                                                                                                

else                                                                                                                                                                 

echo -e " $sec is greatest number "  

fi