#!/bin/bash # Handling arguments while getopts "d:" opt; do case $opt in d) file_name=$OPTARG ;; *) echo "Usage: $0 -d " exit 1 ;; esac done if [ -z "$file_name" ] || [ ! -f "$file_name" ]; then echo "File not found or not specified. Usage: $0 -d " exit 1 fi # Reading a file and converting its contents into an array mapfile -t numbers < <(tr ' ' '\n' < "$file_name") # Number of elements count=${#numbers[@]} echo "Number of elements: $count" # First 10 elements first_ten=("${numbers[@]:0:10}") echo "First 10 elements: ${first_ten[*]/,/, }" # Last 10 elements last_ten=("${numbers[@]: -10}") echo "Last 10 elements: ${last_ten[*]/,/, }"