#!/bin/zsh if [ "$1" = "" ]; then echo 'Name?' exit 1 fi name="${${1%.rb}//-/_}" max_num=(test*(.On[1])) let next_num=${max_num[1][6,9]}+1 new_file="test-$(printf '%04d' ${next_num})${name}.rb" cat > "$new_file" < "FIXTHIS" test "data/FIXTHIS" do # INSERT COMMANDS hash_tmp end EOF echo "New file is $new_file"