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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started