Learn use of options in a Command In Linux Terminal

0

Options can be used to alter the behavior of a command. In the previous blog, the ls command was used to list the contents of a directory. In the following example, the -l option is provided to the ls command, which results in a "long display" output, meaning the output gives more information about each of the files listed:


Note: In the command above, -l is a lowercase letter "L".

Often the character is chosen to be mnemonic for its purpose, like choosing the letter l for long or r for reverse. By default, the ls command prints the results in alphabetical order, so adding the -r option will print the results in reverse alphabetical order.



Multiple options can be used at once, either given as separate options as in -l -r or combined like -lr. The output of all of these examples would be the same:


As explained above, -l gives a long listing format while -r reverses the listing. The result of using both options is a long listing given in reverse order:



Ultimately, commands can use many combinations of options and arguments. The possibilities for each command will be unique. Remember the aptitude easter egg?




It is possible to alter the behavior of this command using options. See what happens when the -v (verbose) option is added:




By combining multiple -v options, we can get a variety of responses:




Remember multiple options can be denoted separately or combined:


Keep adding -v options to see how many unique responses you can get!


Post a Comment

0Comments
Post a Comment (0)