|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Navigating directories with * / . and ..
I would be very happy (after a lot of fruitless searching) if someone could explain the meaning of these variations on the ls command:
ls */ ls */. ls */./ I understand the basic use of ls already eg ls -al but am wanting to list from different points in the file structure without having to leave the directory I am in and my experimenting has left me confused. Also in the examples above what is the correct term for the characters after the "ls"? Are they correctly called operators? Or is that the wrong term? Thanks. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
The characters
? (question mark) and
* (asterisk) are called wildcards. The asterisk represents zero or more characters. Code:
$ ls doc_1.txt doc2.txt f1.csv f2.csv fl3.csv pic_1.jpg pic_2.jpg $ ls *.txt doc_1.txt doc2.txt The question mark represents only one character. Code:
$ ls doc_1.txt doc2.txt f1.csv f2.csv fl3.csv pic_1.jpg pic_2.jpg $ ls ???.csv fl3.csv .. or ../ represents parent directory and ./ represents current directory. So ls */ means list the contents of all directories in current path. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks - that helps a lot.
So how does" */./" differ from "*/." ? I seem to get slightly different results with each and still can't quite see why. Also I understand that * and ? are called wildcards. But what are . .. and / called? |
|
#4
|
|||
|
|||
|
Quote:
The pathname pattern */ expands to the list of directories in the current directory whose names do not have a period as the first character in their name. (Note that a directory is one type of file. Other types of files found on all UNIX and Linux systems include regular files, block special files, character special files, sockets, named pipes (AKA FIFO special files), and symbolic links. Most UNIX and Linux systems have more file types.) The pathname pattern */. expands to the list of files named . (AKA dot in this context) in the directories named by the expansion of */ . The pathname pattern */./ expands to the list of files of type directory named . in the directories named by the expansion of */ . The pathname patterns */ , */. and */./ expand to the same list of files since dot is always a name of the directory in which it is located (unless the filesystem has been corrupted), but they cannot always be treated as synonyms. For example the command: Code:
rmdir */ will remove all empty directories in the current working directory that you have permission to remove, and will print diagnostic messages for directories that are not empty and for directories that you don't have permission to remove, but the command: Code:
rmdir */. will not remove any directories and will give you a diagnostic message (saying you can't remove . for each of the directories named by the expansion of */. . The file named . (AKA dot) is the current working directory. The file named .. (AKA dot-dot) is the parent directory of the current working directory. The file named / (AKA root) is the root directory for the hierarchy of files on the system available to the current process. In the root directory, . and .. may be different names for the same directory. |
| The Following User Says Thank You to Don Cragun For This Useful Post: | ||
radoulov (01-19-2013) | ||
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thank you!! That is the best answer I have ever seen to any question in any forum in ten years. I hope as many people as possible see your answer and learn from it.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Navigating a WebPage with Perl | parthmittal2007 | Shell Programming and Scripting | 3 | 09-19-2012 08:48 AM |
| PERL navigating directories. How do I do it | ShermW0829 | Shell Programming and Scripting | 0 | 03-19-2012 02:49 PM |
| navigating a web interface with a shell script | boyincity | Shell Programming and Scripting | 2 | 02-01-2009 12:33 AM |
| Unix - Navigating the file system | jjaggii | UNIX for Dummies Questions & Answers | 4 | 12-01-2005 03:33 PM |
|
|