I use aliases a lot but right now only for use cases like alias i='sudo apt-get install -y'. I often would like to add an alias in the following form:alias cmd='echo [something] >> /path/to/file' where I would like to substitute [something] with what I enter after the cmd.I can obviously create a one-line script,save it somewhere and make an alias to that command but since I only want to substitute only 1 word in a pipe, is there a simpler way to do this?
How do I make an alias to substitute single word in a piped command?
command line;pipe;alias;arguments
Functions are perfectly suitable for this purpose. For example:cmd() { echo $* >> /path/to/file'; }This is on one line, just like an alias. But it can take parameters.