Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-11-2009, 04:53 PM   #1
Registered: Dec 2007
Posts: 59

Rep: Reputation: 15
Question Two files with the same name in the same directory?

I am running fedora and recently interrupted an installation of some software. I restarted the install and noticed that I have two subdirectories under /tmp that appear to have identical names. I am able to rm one of them but one always persists. I cannot cd into it or remove it. I can create another directory with exactly the same name in that directory.

What's going on? How do I get rid of it?


Old 01-11-2009, 05:00 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
You are correct, they merely
appear to have identical names
You cannot have two files or directories in the same folder with the same name.

Your best bet is to delete with wildcard.

For example, "rm -f /tmp/*xyz*" will delete file/directory "xyz" and " xyz" and "xyz " and "xyz\r\n".

'Hope that helps .. PSM
Old 01-11-2009, 05:03 PM   #3
Registered: Aug 2008
Posts: 107

Rep: Reputation: 16
The /tmp directory is a temporary directory. The filesystem and programs and applications use that directory. You can get information about the ownership of the directories and files with the command ls:

> man ls
> ls -l /tmp

You probably do not have the right permissions to remove the file, or the directory. In the case of a directory, it probably is not empty so can not be removed by an "rm" without the recursive option.

> man rm
Old 01-11-2009, 05:40 PM   #4
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
A way to find out if a filename contains some weird character which is not visible on the terminal is to pass the output of ls to the od command. Restrict the output of ls using wildcards, for example if the "apparently" identical subdirectories are called "testdir", just issue
ls -d *testdir* | od -c
And please, post the output here (you know... we are curious)!

Last edited by colucix; 01-11-2009 at 05:41 PM.
Old 01-12-2009, 06:21 AM   #5
LQ Newbie
Registered: Sep 2007
Location: Stellenbosch, South Africa
Distribution: Ubuntu 12.10 at home, Mac OS X on laptop
Posts: 20

Rep: Reputation: 0
Are you sure they are the same? Or they don't start for example with ~ ?
Give a ls -alh output here.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy files after search in array from this directory to another directory! phanvinhgiap Programming 4 01-04-2009 07:48 PM
Count the number of files in a directory and sub-directories within that directory soumyajit.haldar Linux - Software 4 03-20-2007 07:22 AM
Autozipping files from 1 directory & dropping them in other directory ??? amitsharma_26 Linux - Networking 5 10-22-2005 07:09 AM
copy files from directory to directory without subfile ALInux Linux - General 2 06-03-2005 12:51 PM
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 11:55 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:09 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration