If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > two files with same name in directory

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-22-06, 12:58
bhaizone bhaizone is offline
Registered User
 
Join Date: Feb 2006
Posts: 31
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.
Reply With Quote
  #2 (permalink)  
Old 08-22-06, 13:18
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
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
Reply With Quote
  #3 (permalink)  
Old 08-23-06, 05:51
bhaizone bhaizone is offline
Registered User
 
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?
Reply With Quote
  #4 (permalink)  
Old 08-23-06, 08:53
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
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
Reply With Quote
  #5 (permalink)  
Old 08-23-06, 12:45
bhaizone bhaizone is offline
Registered User
 
Join Date: Feb 2006
Posts: 31
Thanks........this simple error simply shook all my fragile concepts on unix.
Reply With Quote
  #6 (permalink)  
Old 08-23-06, 13:33
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On