LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Editing a directory? (https://www.linuxquestions.org/questions/linux-newbie-8/editing-a-directory-313760/)

Blash 04-16-2005 12:23 AM

Editing a directory?
 
I had accidentally opened a directory in vi, and it has a list of directories and stuff... that totally freaked me out... so what's going on? *nix systems does treat EVERYTHING as a file I guess?

SciYro 04-16-2005 01:17 AM

a directory is basically a collection of pointers to files. Its really file system dependent, and has nothing to do with *nix

if you pass a directory to vi, it will not edit it, but display what files there are, and let you pick what file to edit.

frob23 04-16-2005 01:43 AM

Quote:

Originally posted by SciYro
if you pass a directory to vi, it will not edit it, but display what files there are, and let you pick what file to edit.
If you pass a directory to vim it will display the files and allow you to pick one to edit. If you pass a directory to vi, it opens it as a read-only file and displays the contents.

It is impossible to "edit" a directory, per say. All editing must come through the system calls (unlink(2) and all those). Now, this is not true in very odd and particular circumstances (aka, you need to work very hard at it -- unmounting a disk and reading the whole thing as a file would be one way to circumvent this... but there is no "good" reason to do this).


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