Treat a Command as a Function This addresses a generic question, best illustrated by an example. The command 'tr' translates or strips characters from the contents of a file. Like most commands, it reads and writes files, or standard IO. For example, to strip spaces use: % tr -d " " < in-file > out-file How can we use a command like 'tr' in a shell script, to strip spaces from the contents of a variable? The effect we want is as if we could say: var = tr ($var); The secret is to stream the value of the input parameter, and capture the output stream, thus: In tcsh use: set var=`echo $var | tr -d " "` In sh use: var=$( echo $var | tr -d " " )