0

I just need help understanding how DOS and BASH handle globs. All I ever see is the output but it's not giving me any knowledge on the whole process. How does dir * interpret the wildcard differently then ls *?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by sknake
0

DOS uses "dir *" to match on the file name, such as "dir D*" will run for the currently directory and show all files/dirs beginning with D:

C:\Documents and Settings\scott.SCOTTIE>echo D*
D*

C:\Documents and Settings\scott.SCOTTIE>dir D*
 Directory of C:\Documents and Settings\scott.SCOTTIE
07/22/2009  05:20 PM    <DIR>          Desktop

Linux uses the * to complete file names. so ls D* is equivelant to doing "ls ./Desktop/" in this case and it actually lists the contents of the directory and not the directory itself:

sk@sk:/tmp$ mkdir -p Desktop/test1
sk@sk:/tmp$ echo D*
Desktop
sk@sk:/tmp$ ls D*
test1

As you can see "dir D*" in dos lists the contents of the CWD with files beginning in D, whereas bash expands those directories and lists their contents.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.