I have a file named
123 and one main folder also named
123 which contains a subfolder of the same name.
How can I move file
123 into the folder
123 since both the file and main folder have the same name in terminal?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
It's not possible to have a file and a folder by the same name. If you analyze the name close enough you will notice the names are not the same.
In Linux the files are case different. I'm sure you used
123 as an example just to specify both have the same file name as in
abc. The name can consist of alphabets or numbers. The name can even be spaces or as well as a combination of many symbols. Also the file/directory names are case sensitive.
Files with alphabet names, being case sensitive, means, the following file names are different. You can have a directory of file by the following
abc aBc aBC Abc ABc ABC abC
You can also place a space or a number of spaces anywhere around from the front of all the letters to the end of all the letters as well as in between any of the letters. That would make the directory name different, even though it would have all the same letters and resemble the same.
You can see the details of the names and which ones are folders and which are files with this command:
$ ls -la
In that command the
l is specifying give the long output which will show you more details about the item. Looking at it this way you will have a
d at the far left of the details to specify the item is a folder (a directory). You'll also see the actual item names in a list that will make it easier for you to see the differences. There will be differences unless your system is corrupted if which you might need to run a command such as
fsck to fix.
You might consider adding the content of the
ls command to your question so that the problem are experiencing would be clearer.
You can get to the terminal to execute the
ls command by hitting AltCntrlT
You can move the file to a directory by that name with the same way you would move any file. Type in the full pathname of the filename and the full pathname of the directory name.
This is an example:
(The third line shows the move command of the file with the same name.)
$ mkdir /tmp/test $ mkdir /tmp/test/123 $ echo hello > /tmp/123 $ mv /tmp/123 /tmp/test/123 $ nautilus /tmp/test
If you typed the commands above in a terminal window the last command will bring up a window of the test directory in your
/tmp/ folder. It'll have one directory by the name of 123 with a file in it by the same name.