Opening a directory in command line
Could any one tell me How to open a directory. No book or on line explanation of commands seems to give this. Commands for opening of files do not appear to work for Directories. Manipulating files is covered, cd,cp, mkdir, rmdir etc are covered in books etc,but I could not open a directory with command line.
|
What do you mean by "open" a directory?
|
"cd" = change directory
That is the equivalent of "opening" the directory. To be sure, a directory is just another file, but you cannot see the raw contents with normal tools. |
As per Centinul, what do you mean exactly?
There is a technique in Perl you might want: Code:
opendir(DIR, $dirname) or die "can't opendir $dirname: $!"; |
yap, what do you mead open? are you saying you want to browse directory just like using "cd" command in dos prompt?
In that case just try "ls \" that is to browse your root, or "ls \usr\lib" that is to access folder lib in your usr directory. Hope this can help you |
Refer Centinul's question:What do you mean by "open" a directory?: I mean "How can I view the directory's contents".
I made(or whaterever you call it in Linuxspeak) a directory and named it "babu". With "touch" command, I opened a new file in it. I entered some text in that file. The next day, I wanted to view the contents, add some more text to the file in that directory and make another file in the directory.But for that, I should be able to "open"(as I call it) or view the contents of that directory which I could not do. Chrism01 has given a remedy which is worse than the disease. Please appreciate that such an explanation is a daunting one for a normal and new user. My "instructor" at the place I have joined to learn Linux gives only superficial explanation. I have to necessarily depend only on my enthusiasm and other members' support. |
Code:
ls |
In bash, the simplest way to see a dir's contents is to move into the dir using the 'cd' cmd eg:
cd mydir then list the contents ls then use editor of choice to add text to file. Note that 'touch' creates a file if it does not already exist. If file does already exist, it updates the timestamp to 'now'. 'touch' does NOT open a file... |
Deeply grateful to all for all the support and understanding extended to a novice
|
All times are GMT -5. The time now is 11:43 AM. |