How to edit a directory file on linux

Thanks for viewing my question seemed silly enough. Since directory is a kind of file, I am wandering whether it can be edit or not.I tried several editor but failed to do it. So is there any ways to make it or it is not possible at all. And if it is impossible, why? Thanks again, and best regards!

4

1 Answer

You can do this in vim. e.g.

/tmp/testDirecctoryEdit>ls -l
total 4
-rw-rw-r-- 1 a a 13 Oct 6 09:00 file
-rw-rw-r-- 1 a a 0 Oct 6 09:00 file1
-rw-rw-r-- 1 a a 0 Oct 6 09:00 file2
/tmp/testDirecctoryEdit>vim .

or vim /tmp/testDirecctoryEdit

Now it will list the files under the directory and pretty much edit the file in a way what operations are typically done on a directory
if I move my cursor to "file" and press D, the file will be deleted. Same way I can rename the files, list then by time/size using s.

And if you really want more, you can explore some of the plugins in vim, for directory related tasks. One such plugin is Nerd tree

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like