closed account (Nwb4iNh0)
Do we actually need to put (/) at end of directory path ?


1- cd path/ex
2- cd path/ex/

cd Downloads
cd Downloads/

sometimes works but others give error message "No such file or directory"
it depends on what tool you are using whether it needs it or not.
Using your example, if ex is a directory, then no. If ex is a symlink to a directory, then the two mean different things, so yes.

EDIT: It might not make a difference with cd, but things that take a directory spec, like ls, sure.
Last edited on
he seems to be using unix. Windows can be a little inconsistent across the command line tools. I don't know but I believe unix tools try to follow the same way of doing things near universally, but I only use the major ones, there are so many.... anyway, I was speaking from windows perspective
Last edited on
As said, it depends on the path (file, directory, symlink, ...) and the command. There are only a handful of shell builtin commands. Majority are separate applications and they are free to handle their command-line parameters as they like.

For example, rsync copies files and directories. Whether the source (directory) has trailing slash or not changes what is copied.
Somewhat related, when copying or moving files, I put a slash at the end of the destination if I intend to copy/move the file into a directory:
cp src dir/

That way, if I mistype dir or it doesn't exist, the cp will fail. Without the slash, it would copy src to a file called dir.
Topic archived. No new replies allowed.