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."
> }

Computer Science & Information Technology

You might also like to view...

A rating determined by a search engine based on the number of links to a particular site and the qualities of those links is called ________

a. link checking b. reciprocal linking c. link popularity d. None of the above

Computer Science & Information Technology

Answer the following statement(s) true (T) or false (F)

In network forensics, you have to restore the drive to see how malware that attackers have installed on the system works.

Computer Science & Information Technology