#! /bin/bash printf "Filepath: " read fpath printf "Number of lines to trim from the head: " read htrim printf "Number of lines to trim from the tail: " read ttrim printf "\n" n=$(wc -l "$fpath" | awk '{ print $1 }') hls=$(($n-$htrim)) tls=$(($hls-$ttrim)) tail -n "$hls" -r "$fpath" | tail -n "$tls" -r | awk '!(NR%2){print$0"\t"p}{p=$0}END{print "Total: \t"NR}' > "$fpath"-xformed cat "$fpath"-xformed