Linux – how to properly use $1 in an alias with two arguments

bashbash-scriptinglinux

i have to compare a number of files and I don't want to change the command in two places all the time. so i want to create an alias in bash.

alias gd='gvimdiff $1 dir/$1'

so that i can get

gvimdiff res.tex dir/res.tex

just by typing

gd res.tex

Best Answer

You cannot use aliases this way, however, you can define a function do to the same thing.

function gd() {
    gvimdiff $1 dir/$1
}
Related Question