Do you always need to add the forward slash / at the end of a referenced directory?

When referencing a directory, do you always have to add the forward slash at the end of the directory?

For example, cp biopic/cleopatra.txt historical/

Do you always need the forward slash at the end of the directory historical? lesson.

Whether or not a slash is important and what it does depends on exactly what command you’re using so if you’re doing something you’re not sure about it’s always best to check the manual. For the given example it would make a difference as without the forward slash should that directory not already exist you’d end up creating a new file named historical without error. Probably best to add the slash if you’re intending to copy it to a directory so at least it’ll warn you if you mistype the name.

1 Like