Question: Maxline.sh Script Logic #!/bin/ XXX ########## # Script name: maxlines.sh # Case #1: ./maxlines.sh # Case #2: ./maxlines.sh /bin # Case #3: ./maxlines.sh . #

Maxline.sh Script Logic

#!/bin/XXX

##########

# Script name: maxlines.sh

# Case #1: ./maxlines.sh

# Case #2: ./maxlines.sh /bin

# Case #3: ./maxlines.sh .

# Author: Bob D'andrea

# Editor name:

# Lab Assignment: 2-1

# Functionality: This script reads each file in a directory and counts the

# number of new lines. After determining this count, the file name and new

# line count are saved. The new line count is then compared to each

# file to determine the file with the highest new line count.

# Output an error message because more than one argument is present on the

# command line.

ERROR1="error: can only use 0 or 1 arguments. usage: maxlines.sh [directory]"

ERROR2="error: argument must be a directory. usage: maxlines.sh [directory] "

# Verify that more than one command line argument doesn't exist.

if [[ $# -gt 1 ]]

XXXX

printf "$ERRORX"

exit 1

XX

DIR="."

# Case #2 and 3.

if [[ $# XXX 1 ]]

then

# Is the directory entry a directory?

if [[ -d XX ]]

then

# Assign Variable DIR to command line directory.

DIR="$1"

else

printf "$ERRORX"

exit 1

fi

fi

# All Cases are processed with the following code.

cd $DIR

FILE=$(wc -l `ls` 2>/dev/null | sort XXX | tail -n X | head -n X)

printf "File `echo $FILE | awk '{print $X}'` has the maximum lines with `echo $FILE | awk '{print $X}'` lines. "

exit 0

what to replace XXX with to make it work ?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!