Programming and Scripting :: variable help in bash



How would I make a variable equal to a chain of commands in a bash script?
I made a rather lengthy bash script but would like to shorten it up by somehow making a variable equal to a chain of commands that repeats itself numerous times in my script. Here's one of the few chain of commands I'm talking about:

echo "---------------------------------------------------" >> "$DVDARCHIVE"dvd-"$num"/moved.txt; echo "" >> "$DVDARCHIVE"dvd-"$num"/moved.txt

I tried googling but I couldn't figure out what I needed to do.

thanks for any help!

To make the output of a single command into a variable:
Code Sample
VARIABLE=`command` #those are backticks, not single quotes
or
Code Sample
VARIABLE=$(command)


However, I think a function is more appropriate in your case, if you want multiple commands in it:
Code Sample
function_name(optional_parameters) {
command 1
command 2
command3
}

thanks again mikshaw! A function is what I wanted.

original here.