Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
      You have completed Introduction to the Terminal!
      
    
You have completed Introduction to the Terminal!
Command Arguments are all the same to the shell, but there's a type of argument that many commands treat specially: options. Options generally make some small change to the way a command works.
Command Arguments are all the same to the shell, but there's a type of argument that many commands treat specially: options. options generally make some small change to the way a command works.
- Options usually consist of a dash followed by a single letter.
- For example, we can get the 
lscommand to display all files, even files that are hidden, by passing it the-aoption as an argument:ls -a - On Unix-like systems, a file is treated as "hidden" if its file name begins with a dot.
 - Now that we've told the 
lscommand to list all files, we can see .ninja and .spy files that were hidden previously. 
 - For example, we can get the 
 - Here's another option for the 
lscommand:-t, which causes files to be sorted by the time they were created:ls -t- This shows us that 
bird.txtis the newest file, andstatue.txtis the oldest. - Most options for a command can be combined. If we pass both the 
-aand-toptions tols, it will show us all files sorted by time of creation:ls -a -t - This shows us that the 
.ninjaand.spyfiles are even newer thanbird.txt. 
 - This shows us that 
 
treehouse:~/workspace$ ls -a
.  ..  bird.txt  cart.txt  library  mall  .ninja  offices  .spy  statue.txt
treehouse:~/workspace$ ls -t
mall  offices  library  bird.txt  cart.txt  statue.txt
treehouse:~/workspace$ ls -a -t
.  .ninja  .spy  mall  offices  library  bird.txt  cart.txt  statue.txt  ..
- Most commands accept options, but the set of options and their meaning varies with each command. The 
catcommand, for example, accepts a-noption that numbers each line of output:cat -n bird.txt cart.txt statue.txt- Notice that the option is followed by regular arguments giving the file names to print. With most commands, options are given before the command's regular arguments.
 
 
treehouse:~/workspace$ cat -n bird.txt cart.txt statue.txt
  1  There is a bird here, looking up at the statue with interest.
  2  A stand selling hot dogs and bottles of diet cola.
  3  A statue of a hunter standing over a dead bear. Creepy.
- It can be hard to remember what those single-letter options stand for, so many commands also support longer option names.
- These begin with a double-dash followed by one or more words.
 - For example, the 
lscommand lets you use a--alloption instead of-ato list all files:ls --all - Not all single-letter options have a longer equivalent, though. For example there is no longer version of 
ls's-toption, so you'll have to use the abbreviation:ls --all -t 
 
treehouse:~/workspace$ ls --all
.  ..  bird.txt  cart.txt  library  mall  .ninja  offices  .spy  statue.txt
treehouse:~/workspace$ ls --all -t
.  .ninja  .spy  mall  offices  library  bird.txt  cart.txt  statue.txt  ..
              Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up