1 | 2 | 3 | Current Level: 4 | 5
Look at this example:
ls -F /
This has three parts:
ls
— the command (what to do)-F
— the option (how to do it)/
— the argument (what to do it to)What do each of these mean?
-
(short) or --
(long).Spaces matter Each part of the command must be separated by a space. This is wrong:
ls-F
The shell will look for a command named ls-F
, which doesn’t exist.
Case matters too Options are case-sensitive. For example:
ls -s
shows file sizes (in blocks), while:
ls -S
sorts files by size.
Try it out Navigate to the lesson folder:
cd ~/Desktop/shell-lesson-data
Then run:
ls -s exercise-data
This shows the sizes of the files in the exercise-data
folder.
Try:
ls -S exercise-data
This shows the same files, but sorted by size.
Use options and arguments together Try this example using both:
ls -F /
This lists the contents of the root directory /
, and uses -F
to show which entries are folders.
Example output:
Applications/ Library/ Network/ System/ Users/ Volumes/
The order usually goes:
command [options] [arguments]