LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 11-10-2007, 07:21 AM   #1
hocheetiong
Member
 
Registered: Jul 2007
Location: Penang , Malaysia.
Distribution: red hat linux
Posts: 133

Rep: Reputation: 15
Smile at same directory, is it cannot have same name text file and folder name?


Hi, i have confuse with this: i am in folder /test inside there i have make a directory #mkdir folder1 , than inside /test have a directory name "folder1", now i want to create a text file in same location /test #vim folder1 ,but cannot create this text file? is it folder name and text file or what file also cannot have a same name?


i am in /mnt/hda , now nothing is mount to this directory, i have create a file in this directory, but now i just mount the harddisk partition to this directory mount -t ext3 /dev/hdd1 /mnt/hda than the directory /mnt/hda files which i create before i mount the /dev/hdd1 cannot view after i mount /dev/hdd1?

Thank you.
 
Old 11-10-2007, 07:35 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Quote:
at same directory, is it cannot have same name text file and folder name?
That's right.
Code:
# mkdir folder
# vim folder
~
"folder" is a directory

# touch foo
# mkdir foo
mkdir: cannot create directory `foo': File exists
When you think about it, this behavior is quite reasonable. A directory is a file too... how can you have two files with the same name? How will the computer tell them apart?

Note - you should not be creating user-access directories off root like /text. Create them in your home directory (~/text) or off /usr/share ... the directories are organized that way for a reason. ~/documents is equivalent to My Documents... see?
 
Old 11-10-2007, 07:55 AM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
I have to disagree with Simon Bridge. You may have a folder and a file in the folder with the same name.

Prove it this way: In your home folder ~,
mkdir test
cd test
mkdir folder1
cd folder1
touch folder1
cd ~
ls -R test

test
test/folder1
test/folder1/folder1
 
Old 11-10-2007, 09:06 AM   #4
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Quote:
You may have a folder and a file in the folder with the same name.
I agree, but that's not what he's asking and it is not what I said.
Quote:
i am in folder /test [1] inside there i have make a directory [2] #mkdir folder1 , than inside /test have a directory name [3] "folder1", now i want to create a text file [4] in same location /test #vim folder1 ,but [5] cannot create this text file?
... see?

# pwd ...[1]
/test
# mkdir folder1 ...[2]
# ls ...[3]
folder1
# vim folder1 ...[4]
~
"folder1" is a directory ...[5]

Last edited by Simon Bridge; 11-10-2007 at 09:14 AM.
 
Old 11-10-2007, 09:13 AM   #5
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
See the other question:
Quote:
i am in /mnt/hda , now nothing is mount to this directory, i have create a file in this directory, but now i just mount the harddisk partition to this directory mount -t ext3 /dev/hdd1 /mnt/hda than the directory /mnt/hda files which i create before i mount the /dev/hdd1 cannot view after i mount /dev/hdd1?
# pwd
/mnt/hda
# touch dummy
# ls
dummy
# mount -t ext3 /dev/hdd1 /mnt/hda
# ls
documents music archive (or whatever is in there, but not dummy)
# umount /mnt/hda
# ls
dummy

This too is the correct behavior. It hasn't overwritten "dummy", all it means is that /mnt/hda is now about a different drive.
 
Old 11-10-2007, 09:31 AM   #6
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
I stand corrected. On re-reading the original post, I see my error. Thanks for correcting me.
 
Old 11-10-2007, 11:20 AM   #7
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Quote:
I stand corrected. On re-reading the original post, I see my error. Thanks for correcting me.
No worries... the English was pretty mangled... now OP chimes in to say you were right all along
 
  


Reply


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
KDE per folder display preferences file ? was .directory DaveQB Linux - Desktop 3 01-12-2007 10:15 AM
Utility Needed - list folder tree and files in text file Optiker Linux - Software 21 11-17-2006 03:46 PM
Removing a Directory from the Terminal without deleting each file or folder lennysokol Linux - General 4 05-31-2005 12:30 AM
outputting data from a directory to a text file? minm Linux - Newbie 2 12-19-2004 07:46 PM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 03:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:12 AM.

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