Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2006
    Posts
    31

    Unanswered: two files with same name in directory

    Recently I found a very strange thing while working.....I could see two files with the same name co-existing in the same directory. As far as I know it can't be possible.....also I observed they had different i node numbers.......Is there any remote possibility for two files with same name to coexist....even for a small time.

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


    Yes if one of the file names has space(s) in the name.

    Code:
    $ ls -alp
    total 8
    drwxr-xr-x   2 lkbrwn   dba          512 Aug 22 13:16 ./
    drwxrwx---   5 lkbrwn   dba         1024 Aug 22 13:13 ../
    -rwxr-xr-x   1 lkbrwn   dba           91 Aug 22 13:14 file1
    -rwxr-xr-x   1 lkbrwn   dba           91 Aug 22 13:16 file1  
    $

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Feb 2006
    Posts
    31
    but how do I make such files....how to give spaces to file names...when I am trying to give spaces before or after the file name I am getting the same file. How to create file with same names?

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


    Supply the file name in quotes:

    Code:
    $ ls -alp
    total 6
    drwxr-xr-x   2 lkbrwn   dba          512 Aug 23 08:51 ./
    drwxrwx---   5 lkbrwn   dba         1024 Aug 22 13:13 ../
    -rwxr-xr-x   1 lkbrwn   dba           91 Aug 23 08:51 MyFile
    $ cp MyFile "My File"
    $ ls -alp
    total 8
    drwxr-xr-x   2 lkbrwn   dba          512 Aug 23 08:51 ./
    drwxrwx---   5 lkbrwn   dba         1024 Aug 22 13:13 ../
    -rwxr-xr-x   1 lkbrwn   dba           91 Aug 23 08:51 My File
    -rwxr-xr-x   1 lkbrwn   dba           91 Aug 23 08:51 MyFile
    $

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  5. #5
    Join Date
    Feb 2006
    Posts
    31
    Thanks........this simple error simply shook all my fragile concepts on unix.

  6. #6
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool



    To find out if there are and how many spaces after the file name do this:
    Code:
    ls -1|awk '{print ">"$0"<";}'


    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •