This is probably a very simple thing but I can’t find an answer, possibly because I don’t know what terms to use in search.
How do I use an alias of a path with mv or cp? Or even cd?
In /etc/bash.bashrc I have:
alias docs=‘/media/docs
cd docs
Gives “No such file or directory”
Yet:
docs
Gives “Is directory”
With alias docs=‘cd /media/docs’ and by typing docs I get into the directory. Obviously I can’t use that alias with mv or cp though.
Maybe this isn’t even an intended use of alias but still. Why doesn’t it work?


As already pointed out in other comments here,
aliasis used specifically to define a new shell command and in order to define some arbitrary text substitution to be used anywhere in a commandline you’ll need to use a variable instead, but for the specific case ofcdthere’s also a feature calledCDPATHthat you might be interested in learning about:https://writesoftwarewell.com/cdpath-easily-navigate-directories-in-the-terminal