I can't remember how to append a command to a shell script. I searched for append, add, concat, and more without success.
Basically I have
belly = tail -n +"$HEAD" "$1" | head -n $((TAIL-HEAD+1))
if [ -z "${NUMBER+x}" ]; then # check if NUMBER exists
tail -n +"$HEAD" "$1" | head -n $((TAIL-HEAD+1))
else
tail -n +"$HEAD" "$1" | head -n $((TAIL-HEAD+1)) | cat -n
fi
and it works fine, but I don't like the duplicate logic. I know that I could use a function or eval, but is there a simpler way to do this? In my head I have something like this:
belly = tail -n +$HEAD $1 | head -n $((TAIL-HEAD+1))
if [ -z "${NUMBER+x}" ]; then # check if NUMBER exists
belly
else
belly | cat -n
fi
But it doesn't work. What am I missing?