User Tools

Site Tools


wiki:options2016

–> Quiz
–> Assignment
–> Further Exercises
–> Canvas
–> Summit

OPTIONS

Up to this point, we have used commands without arguments and commands with arguments. In addition to this, we can execute commands with options. Options are bells and whistles we can append to our commands to customize the way the shell interprets the commands.

Here are a few options for the command ls courtesy of The Linux Command Line :

Options are added after the command itself but before any arguments.

command [options] [arguments]
command [options] <arguments>

[] – optional. The command will work with or without these
<> – required. The command requires these arguments

Short options take one dash. Long options take two dashes

Further, short options can often be lumped together.

For example, the following commands do the same thing…

$ls -a
$ls --all

And these commands do the same thing…

$ls --all --human-readable -l
$ls -a -h -l
$ls -ahl

:!: Exercise: Let's obtain a dataset to allow us to explore ls:

  • Download the following file: 160825_options_ex.tgz
  • Using Finder/Explorer, navigate to the location where you downloaded the file.
  • Double click on the .tgz file to decompress it.
  • If you need to, move the resulting expanded directory and its contents to a location you can easily manipulate in the terminal.
  • Open your terminal and navigate (cd, pwd, ls) to the directory 160825_options_ex.

:!: Exercise: Try executing ls commands:

  • Convince yourself that ls -a and ls --all do the same thing.
  • Try ls -alh
  • Which combination of ls options would you execute to list the contents in the following order and format:
total 184
-rw-r--r--@ 1 erinonish  staff    99B Aug 24 19:38 ce11_chrom_sizes.txt
-rw-r--r--@ 1 erinonish  staff   800B Aug 24 19:51 README_download.txt
-rw-r--r--@ 1 erinonish  staff   1.4K Aug 24 19:39 mm10_chrom_sizes.txt
-rw-r--r--@ 1 erinonish  staff    11K Aug 24 19:41 hg38_chrom_sizes.txt
-rw-r--r--@ 1 erinonish  staff    23K Aug 24 19:42 danRer10_chrom_sizes.txt
-rw-r--r--@ 1 erinonish  staff    44K Aug 24 19:37 dm6_chrom_sizes.txt

Making & Removing

wiki/options2016.txt · Last modified: 2017/08/24 09:35 by erin