Question
Write a shell script to display the line count over several files(given as arguments)
Answer :
Word Count : 289
_________ _________ _________ __________ ________ ________ _______ ________ __________ ____.
___ ___ ______ _________ ___.
_____ _____ __________ ______ ____ ______ ______.
__________ _______ ____ __________ _________ _______ ___ _____ _________ _____ ____ ___.
______ ____ ____ _________ _____ _________ _________ __________ ______ __________ ______.
_____ _______ ______ __________ ____ ___ _____ __________ _________ _________ _______.
________ _____ _______ ________ __________ _________ _______ ______ _________ _________.
____ _________ ___ _______ _______ ______ ____ ____ ____ __________ _____.
____ _________ _____ _____ __________ _____ ________ ______.
_____ _____ _________ _______ __________.
_______ __________ ____ ________ ________ __________ _______ _____ ____ _______ _________.
______ _______ ______ _________ _______ _________ ____ ____ ________ __________ ___.
_______ ____ _____ ____ ____ _____ ______ _________ _____.
________ ________ ______ ___ __________ _________.
___ ___ _______ ___ _____ __________.
________ _________ ____ ______ _______ _________ ____ _______ _________ __________ ________ ______.
________ __________ ________ ______ ___ _________ ________ ________.
_____ ______ __________ _____ __________ _______ ____ ________ ________.
_________ ________ _______ ______ _________ ______ _______.
___ ______ _______ ____ ______ ____ _______ _________ __________ ______ __________.
______ __________ _________ ___ _______.
Skip in 10
Here is a shell script that displays the line count over several files given as arguments:
#!/bin/bash
# Check if arguments are provided
if [ $# -eq 0 ]
then
echo "Error: No arguments provided. Usage: $0 file1 file2 file3 ..."
exit 1
fi
# Loop through each file and display the line count
for file in "$@"
do
if [ -f $file ]
then
echo "$file: $(wc -l < $file) lines"
else
___ ___ ______ _________ ___.
_____ _____ __________ ______ ____ ______ ______.
__________ _______ ____ __________ _________ _______ ___ _____ _________ _____ ____ ___.
______ ____ ____ _________ _____ _________ _________ __________ ______ __________ ______.
_____ _______ ______ __________ ____ ___ _____ __________ _________ _________ _______.
________ _____ _______ ________ __________ _________ _______ ______ _________ _________.
____ _________ ___ _______ _______ ______ ____ ____ ____ __________ _____.
____ _________ _____ _____ __________ _____ ________ ______.
_____ _____ _________ _______ __________.
_______ __________ ____ ________ ________ __________ _______ _____ ____ _______ _________.
______ _______ ______ _________ _______ _________ ____ ____ ________ __________ ___.
_______ ____ _____ ____ ____ _____ ______ _________ _____.
________ ________ ______ ___ __________ _________.
___ ___ _______ ___ _____ __________.
________ _________ ____ ______ _______ _________ ____ _______ _________ __________ ________ ______.
________ __________ ________ ______ ___ _________ ________ ________.
_____ ______ __________ _____ __________ _______ ____ ________ ________.
_________ ________ _______ ______ _________ ______ _______.
___ ______ _______ ____ ______ ____ _______ _________ __________ ______ __________.
______ __________ _________ ___ _______.
IGNOU ACADEMY
Your IGNOU journey, made easier.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
Continue Reading — It's Free
Sign in with Google to unlock more of this answer.
✓ Free access
✓ Unlock up to 60% of the answer
✓ No payment required
✓ Unlock up to 60% of the answer
✓ No payment required
Quick Google sign-in. No separate registration form.