0

I know that / stands for folder, but there is one thing I don't get.

Command to illustrate the problem:

mv ~/Documents/newfolder ./anothernamefolder

Why there is / here? What does it do? Why can't I type:

mv ~/Documents/newfolder . anothernamefolder
2

2 Answers 2

1

As per my comment's link (What does the ./ mean (dot slash) in linux?), and as you correctly think, slash (/) is a directory "representation".

In your two examples, the slash represents different things though:

mv ~/Documents/newfolder ./anothernamefolder

move newfolder from Documents located under user home directory (~), to current directory (./) and name it anotherfolder.

In the second one

touch {jan,feb,mar,apr}_{2017..2019}/file{1..100}

you touch files in number of directories.

So for every directory specified in the command: {jan,feb,mar,apr}_{2017..2019} create files file{1..100}.

Why there is "/" here? What does it do? Why I can't type:

As above, ./ is representation of current directory.

If you used

mv ~/Documents/newfolder . anothernamefolder

command, you'd get an error, as you'd be specifying ambiguous redirections:

$ mv ~/Documents/newfolder . anotherfolder
usage: mv [-f | -i | -n] [-v] source target
       mv [-f | -i | -n] [-v] source ... directory

You could use dot . to move, but that would simply move folder called newfolder without changing its name.

$ mv ~/Documents/newfolder .
$ ls
newfolder
2
  • 1
    Thank you kindly for your answer. So basically I can understand mv ~/Documents/newfolder ./anothernamefolder as mv ~/Documents/newfolder ~/Desktop/anothernamefolder (in this example the . is a desktop) am I right?
    – Wallace
    Commented Jul 15, 2019 at 20:09
  • yup, exactly that.
    – Bart
    Commented Jul 15, 2019 at 20:11
1

/ separates directories (folder is a gui-term).

In the first argument to your mv-command /'s separate ~, Documents and newfolder, signaling that each is a subdirectory of the previous.

The same is true for the second argument, saying that you want to move files to anothernamefolder which is a subdirectory of .. As . (in that context) means the current directory, ./ is unneeded.

Just removing the /, as you suggest, changes the meaning of the command, to say that you also (in addition to ~/Documents/newfolder) want to move . to anothernamefolder. That is not possible and will cause mv to give an error.

1
  • 1
    No folder is an MS-Windows term. A bad metaphor. A thing can be in more than one directory (and so can files). A thing can be in only one folder, not true for files, on Unix file-systems, or NTFS. Commented Jul 15, 2019 at 21:58

Not the answer you're looking for? Browse other questions tagged .