|
|
|
@ -10,19 +10,19 @@ if [ ! -e "$(which pv)" ]; then
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
function simplify_size_number {
|
|
|
|
function simplify_size_number {
|
|
|
|
declare -i bytes=$1
|
|
|
|
local declare -i bytes=$1
|
|
|
|
declare -i kilobytes=$((bytes/1024))
|
|
|
|
local declare -i kilobytes=$((bytes/1024))
|
|
|
|
|
|
|
|
|
|
|
|
size_str=""
|
|
|
|
local size_str=""
|
|
|
|
|
|
|
|
|
|
|
|
if [ $kilobytes -lt 1024 ]; then
|
|
|
|
if [ $kilobytes -lt 1024 ]; then
|
|
|
|
size_str="${kilobytes}kb"
|
|
|
|
size_str="${kilobytes}kb"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
declare -i megabytes=$((kilobytes/1024))
|
|
|
|
local declare -i megabytes=$((kilobytes/1024))
|
|
|
|
if [ $megabytes -lt 1024 ]; then
|
|
|
|
if [ $megabytes -lt 1024 ]; then
|
|
|
|
size_str="${megabytes}mb"
|
|
|
|
size_str="${megabytes}mb"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
declare -i gigabytes=$((megabytes/1024))
|
|
|
|
local declare -i gigabytes=$((megabytes/1024))
|
|
|
|
size_str="${gigabytes}gb"
|
|
|
|
size_str="${gigabytes}gb"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
@ -33,10 +33,15 @@ while getopts ${optstring} args; do
|
|
|
|
case $args in
|
|
|
|
case $args in
|
|
|
|
o) output_file=${OPTARG} ;;
|
|
|
|
o) output_file=${OPTARG} ;;
|
|
|
|
:) echo "Output file required." ;;
|
|
|
|
:) echo "Output file required." ;;
|
|
|
|
|
|
|
|
# TODO: Expand this into something nicer looking.
|
|
|
|
h) echo "Usage: nyan -o [OUTPUT FILE] [INPUT FILE]..." && exit 0 ;;
|
|
|
|
h) echo "Usage: nyan -o [OUTPUT FILE] [INPUT FILE]..." && exit 0 ;;
|
|
|
|
esac
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
done
|
|
|
|
shift $((OPTIND-1))
|
|
|
|
shift $((OPTIND-1))
|
|
|
|
|
|
|
|
if [ -z "$output_file" ]; then
|
|
|
|
|
|
|
|
echo "Error: no output file specified."
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo "Concatenating files..."
|
|
|
|
echo "Concatenating files..."
|
|
|
|
declare -i total_size=0
|
|
|
|
declare -i total_size=0
|
|
|
|
@ -54,6 +59,8 @@ for fname in "$@"; do
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Make sure that output_file does not exist. Maybe add an overwrite switch.
|
|
|
|
|
|
|
|
|
|
|
|
if [ $abort -eq 0 ]; then
|
|
|
|
if [ $abort -eq 0 ]; then
|
|
|
|
cat "$@" | pv -epts "$total_size" > "$output_file"
|
|
|
|
cat "$@" | pv -epts "$total_size" > "$output_file"
|
|
|
|
echo "Done!"
|
|
|
|
echo "Done!"
|
|
|
|
|