The purpose of this lesson is to show you how a Unix command can have options, filenames, and arguments.
As we've seen in the Login lesson, the basic unit of interaction with Unix is through a Unix command issued at the shell prompt.
We looked at basic Unix commands that consisted just of one or a few "words" or strings of characters.
However, a Unix command can have more parts to it.
Parts of a Unix command include the command name itself plus options, filnames, and arguments.
An option on a Unix command tells Unix to perform the command in a particular way.
Most Unix options are composed using a minus sign - followed by one or more letters.
$ uname -r 2.0.36 $ uname -s Linux $ uname -p unknown $ uname -m i686 $ uname -v #5 Wed Dec 16 18:09:02 CST 1998 $ uname -a Linux cerise.propagation.net 2.0.36 #5 Wed Dec 16 18:09:02 CST 1998 i686 unknown $ uname Linux $ uname -rsp Linux 2.0.36 unknown $
Many Unix commands operate on certain files. For example, the vi command takes a filename to start an editing session.
You list these filenames right after the Unix command.
You can refer to more than one file by using wildcard symbols for filenames.
Here is an example of the ls command used without filenames, with filenames, and with wildcard symbols for filenames.
$ ls apple.txt applebad.txt applegood.txt bag.txt basket.txt fish $ ls bag.txt bag.txt $ ls applebad.txt bag.txt applebad.txt bag.txt $ ls *.txt apple.txt applebad.txt applegood.txt bag.txt basket.txt $ ls a* apple.txt applebad.txt applegood.txt $ ls b??.txt bag.txt $
Arguments are pieces of information that the Unix command needs in order to do its job. If a command requires one or more arguments to operate, and you don't give it any, default arguments will be used to produce the results.
Here is an example of using the cal command with zero and two arguments.
Notice that with zero arguments, the month and year arguments that the command assumed by default were the current month and year.
$ date Fri Aug 29 09:36:55 CDT 2003 $ cal August 2003 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 $ cal 02 2001 February 2001 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 $
As you've seen in this lesson, you can use symbols in commands to do all sorts of things in referencing files and directories.
Look at this demonstration of the ls command and try out for yourself all the different options possible with it.