![]() | Command options and arguments In the last module, you were introduced to two operating system commands - passwd and exit. The passwd command was used to change your login password, and the exit command was used to logout from the system. Running these commands was relatively basic because you did not need to include any command options or arguments with them. You would add a command option after a command name when you want the command to do something different from its default (also called standalone) operation. The format for specifying options with a command is: $ command -option1 -option2... -optionN We will use the ls command to illustrate the use of a command option. As you may already know, ls by itself lists the contents of a directory. When the -l option is added to ls, a long or detailed listing of the directory contents will be displayed. Notice that there needs to be a space between the command and the option: $ ls -l A command argument is something you pass to the command to be operated upon. The name of a file is an example of a typical command argument. You can include both options and arguments when invoking a command, or like options, you can use arguments by themselves. The format for using a command with options and arguments is: $ command -option1 -option2... -optionN argument1 argument2... argumentN We will use the ls command again to illustrate the use of an argument: $ ls myfile2 In this example, myfile2 is the argument being passed to ls. |
| * You are viewing a page from LiveFire Labs' sample online UNIX training course. Click here if you do not see a blue and green frame around this page, or view the detailed description for this course. LiveFire Labs - Online UNIX Training |