Ok. So actually the problem is replacing arguments in the middle of the command.
Correct! You might also be interested in this recent thread, from about 6 posts down onwards: https://bbs.archlinux.org/viewtopic.php?id=140146
Please remember to mark the thread solved .
]]>alias foo="bar baz"
and
foo () { bar baz $1; }
are equivalent:
$ foo <some argument>
Aliases simply don't take arguments, functions do (just like the mathematical functions).
Well, though one can of course use arguments with aliases, e.g.
alias p='sudo pacman'
still allows you do specify options, etc of course, such as:
p -Syu foobar
Might be "better"/less confusing to say that an alias is just a simple string replacement, and for more "complicated" things one needs indeed to e.g. use a function.
]]>Wasser wrote:But why does this happen?
Aliases simply don't take arguments, functions do (just like the mathematical functions).
Thanks
]]>But why does this happen?
Aliases simply don't take arguments, functions do (just like the mathematical functions).
]]>I will use a function (the single quote does not work).
But why does this happen?
]]>encrypt() { openssl aes-256-cbc -a -salt -in "$1" -out "$2"; }
' instead of "
Also, remember to reload your .bashrc after changing it.
]]>I'm not very well-versed in the art of bash scripting or anything and I am having some trouble doing an alias that uses two arguments.
My case:
My command:
"openssl aes-256-cbc -a -salt -in a.txt -out a.txt.aes"
What I wanted to do was an alias like this:
alias encrypt="openssl aes-256-cbc -a -salt -in $1 -out $2"
But it's not working. Actually, even using just the $1 and leaving a fixed string as $2 is not working.
Can anyone give me some help? Thanks!
]]>