Probably a stupid question but...

corwin

Diamond Member
Jan 13, 2006
8,644
9
81
OK I'm taking an intro to Linux course and I'm stumped on something. I know the ls command shows the directory contents and folders and the ls * shows the same thing and also the sub-directories, but why? What is the wildcard actually doing? I can't seem to find the answer anywhere...

Told you it was a stupid question
 

bobross419

Golden Member
Oct 25, 2007
1,981
1
0
From `man ls`
If no operands are given, the contents of the current directory are displayed. If more than one operand is given, non-directory operands are displayed
first; directory and non-directory operands are sorted separately and in lexicographical order.

`ls *` is the equivalent of `ls file1 file2 subdir1 subdir2 subdir3 `.
 

corwin

Diamond Member
Jan 13, 2006
8,644
9
81
From `man ls`


`ls *` is the equivalent of `ls file1 file2 subdir1 subdir2 subdir3 `.

Whatever version is on the server we're using doesn't have that listed in the man info for ls...I'm guessing it's pretty old...in any case it's basically just displaying the contents of the current directory as well as the contents of every sub-directory but not any further than that...and those other options you have listed there don't work for this system either
 

bobross419

Golden Member
Oct 25, 2007
1,981
1
0
"file1 file2..." isn't an option... It was an example of manually entering each file and subfolder at the command line.

Given a directory structure:
Code:
topDir
 subDir1
  file1
 subDir2
  file 2
  subSubDir1
   file3

I know that looks like crap.

Just running `ls` with no flags would be the same as running `ls .` -- Since `ls` only lists the contents of the directory passed on the command line you get the contents of topDir:
Code:
# ls
  subDir1
  subDir2

If you wanted to see the contents of subDir1 you'd need to either `cd` into subDir1 or provide `ls` with subDir1 as the folder to use:
Code:
# ls subDir1
  file1

If you wanted to see the contents of both subDir1 AND subDir2 you can pass both:
Code:
# ls subDir1 subDir2
  subDir1:
    file1
  subDir2:
    file2
    subSubDir1

Because of bash command line expansion, the * (wildcard) will be expanded to the full list of files in topDir:
Code:
# ls *
  subDir1:
    file1
  subDir2:
    file2
    subSubDir1

If you wanted to see everything in the entire directory tree, you'd need to use the recursive flag (-R):
Code:
# ls -R
  subDir1:
    file1
  subDir2:
    file2
    subSubDir1
  subDir2/subSubDir1
    file3

Hopefully this helps clear things up.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |