Files
G4G0-1/Semester 2/Computer Systems Internals & Linux/Trimester 2 Assignment/q1.sh

23 lines
322 B
Bash

#!bin/bash
if [ $# -ne 2 ]; then
echo "Please provide 2 files as arguments"
exit 1
fi
if [ ! -f "$1" ] || [ ! -f "$2" ]; then
echo "Both arguments must be files"
exit 1
fi
print() {
file="$1"
echo "$file"
head -n 2 "$file"
}
print "$1"
print "$2"
echo "Total number of characters is: $(cat "$1" "$2" | wc -c)"