#!/bin/bash optstring="o:" input_files="" while getopts ${optstring} args; do case $args in o) output_file=${OPTARG} ;; :) echo "Output file required." ;; esac done shift $((OPTIND-1)) echo $output_file echo "Concatenating files..." declare -i total_size=0 for fname in "$@"; do #TODO: Make sure this file exists and isn't a directory! current_file_size=$(stat -c%s "$fname") let total_size=$total_size+$current_file_size echo "${fname} is ${total_size}b and valid." done cat "$@" | pv -epts "$total_size" > "$output_file" echo "Done!"