For example, here I use makealias to avoid having to quote
makealias mycat cat `ls | sed '1,/!*/d'` | less[CTRL-d] alias mycat 'cat `ls | sed '\''1,/\!*/d'\''` | less'
I typed the
command and the line starting with
got back an alias definition with all of the quoting done correctly.
The properly quoted alias definition is sent to the standard output. That line is what you would use to define the alias. 
 [The mycat alias runs cat on all files with names later in the alphabet than the argument you type. The output of cat is piped to thepager. For example, let's say your current directory has the files afile, count, jim, and report. Typing
countwould display the files jim and report. -JP ]
And here are the quote and makealias aliases themselves:
alias quote "/bin/sed -e 's/\!/\\\!/g' \ -e 's/'\\''/'\\'\\\\'\\''/g' \ -e 's/^/'\''/' -e 's/"\$"/'\''/'" alias makealias "quote | /bin/sed 's/^/alias \!:1 /' \!:2*"
Pretty gross, but they do the job.
- in comp.unix.questions on Usenet, 17 February 1991