Write a function that takes a directory name as an argument and writes to standard output the maximum of the lengths of all filenames in that directory. If the function’s argument is not a directory name, write an error message to standard output and exit with nonzero status.
What will be an ideal response?
$ function maxfn () {
> declare -i max thisone
> if [ ! -d "$1" -o $# = 0 ]
> then
> echo "Usage: maxfn dirname"
> return 1
> fi
>
> max=0
> for fn in $(/bin/ls $1)
> do
> thisone=${#fn}
> if [ $thisone -gt $max ]
> then
> max=$thisone
> fi
> done
> echo "Longest filename is $max characters."
> }
You might also like to view...
A container that provides quick access to elements at the front and the back of the list is a
a. stack b. queue c. deque d. All of these e. None of these
The accompanying figure shows an instance of the _____ app in Windows 10.
?
A. ?Contact Support B. ?Personalization C. ?Privacy of Accounts D. ?Devices & Drivers
In a Word table, the intersection of a row and a column is called a(n) ____________________, and is filled with text.
Fill in the blank(s) with the appropriate word(s).
_________ are analogous to a burglar guessing a safe combination by observing how long it takes to turn the dial from number to number.
A. Digital standards B. Mathematical attacks C. Ciphers D. Timing attacks