Question

Write a shell script to display the line count over several files(given as arguments).

30 Nov 2023
Answer :
Word Count : 432

Sure thing! In Linux, you can use a simple shell script to display the line count of multiple files. Here's a basic example:

```bash
#!/bin/bash

# Check if at least one argument is provided
if [ "$#" -lt 1 ]; then
    echo "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
        lines=$(wc -l < "$file")
        echo "File: $file, Line Count: $lines"
    else
        echo "File '$file' not found."
    fi
done
```

Save this script to a file, let's

__________ _____ _____ _____ __________ ______ ___ ____ ______ ___.
__________ _________ ____ _______ ______ _____ _________ ___ ___.
___ ________ ________ ______ ____ ______ _______ ___ ______ _______ ________ ____.
_________ ___ _______ _____ __________ _____ _________ _____ _____ ___ ______.
_______ ___ ____ _____ ______ ______ _____ __________ ___.
______ _____ __________ ________ _________ _____.
________ _______ ______ ______ ___ ________ ____ ___ ________ ____ ____.
_____ _________ _____ ___ _______ _______ _______ ____ _________ _____.
___ _____ _________ ____ ____ ________ _______ ________ _________ ______ _____.
_______ ____ _____ _____ ___ _______ ______ __________ _________ _________ _________ _________.
_____ ______ ______ ____ ________ ___ ____ _________ ____.
_________ _____ ________ __________ ____ _______ _________ ________.
___ ___ __________ ___ _____ ________ ____ _____ _________ ______.
________ _______ _________ ______ _____ ______ _____ ______ _____.
_____ ___ ___ __________ ___ ____ ____ _______ ___ ________.
________ _________ ____ ____ ___ _______ __________ _____.
_____ _______ _________ ____ _______ _________.
__________ ____ ____ ___ _____ ____ _____ _____ ________.
___ ____ __________ _________ ____ ______ ______.
____ ___ ___ _______ _____.
______ ____ ________ __________ ________ ___ ______.
________ ________ _________ _________ ________ _____ _______.
___ _____ ____ ________ ________ ________ _______ ___ _______ _______ ___ _____.
_______ _______ _____ ___ _____ ______.
__________ ________ ___ ____ ________.
___ ___ ____ ______ _________ _______.
___ _______ _________ _________ _________ _____ ____ ____.
_________ _______ _________ ________ ___.
__________ ________ ______ ____ _______ ___ ____ ____ _____.
_______ _________ _________ __________ _____ _____ _____ _________.
_____ ________ ___ _________ _____ __________ ______ _________.
___ ______ ___ _________ ________ ______.
___ ________ _____ ___ _________ ______ _____ _________.
____ __________ _______ _________ ___ ______ ___ ______ _________ ________ _______ ____.
_________ __________ _____ _______ __________ _____ ___ ____ _____.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCSL 204 2023 - Write a shell script to display the line count over several files | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→