Options & Arguments [SOLVED]

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
chazb
Level 5
Level 5
Posts: 713
Joined: Wed Nov 30, 2016 2:56 am
Location: Oklahoma

Options & Arguments [SOLVED]

Post by chazb »

Learning how to use the command line. If all options are arguments, but not all arguments are options, what else can an argument be?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
JerryF
Level 16
Level 16
Posts: 6554
Joined: Mon Jun 08, 2015 1:23 pm
Location: Rhode Island, USA

Re: Options & Arguments

Post by JerryF »

You'd have to look at a particular command for what the options and arguments would be.

For example, the ls command. Type ls --help and it will give you information.

Also man ls gives complete details.
johnny9308

Re: Options & Arguments

Post by johnny9308 »

As I understand, Options are the things that have a specific name and are prefixed by a standard symbol like "-" or "--" or "/" (Windows). Example: --color or --all or -f. Short Options are like "-p", Long Options are like "--print" and they can refer to the same thing (it's up to the user to decide which they prefer).
Arguments are a value you specify, like "red" or "/etc/somefile.conf". Arguments can sometimes stand on their own or follow an Option.
I also noticed a third type mentioned in the "dd" man page called Operand. Example: dd if=/some/input of=/some/output where the values following the command are called Operands. I'm not sure how widespread that terminology is.

As an example of Options and Arguments, say you had a command called "myprint" that could be called in several ways:

$ myprint /my/file ## print a file
$ myprint -q /my/file ## print a file, silence screen output
$ myprint --color red -q /my/file ## print a file in the color red, silence screen output

--color is an Option that expects a color argument.
"red" is an Argument
-q is an option (with no Argument)
/my/file is an Argument

As to why "all options are arguments", I suspect that is only in the general sense where a command takes a bunch of parameters that alter its behaviour and someone may call all of that "arguments", though I believe the distinction between options and arguments would be considered more precise.
Hoser Rob
Level 20
Level 20
Posts: 11806
Joined: Sat Dec 15, 2012 8:57 am

Re: Options & Arguments

Post by Hoser Rob »

I did a quick search of "computer science difference between option and argument" and this was at the top of the list:

https://stackoverflow.com/questions/364 ... -parameter
For every complex problem there is an answer that is clear, simple, and wrong - H. L. Mencken
DAMIEN1307

Re: Options & Arguments

Post by DAMIEN1307 »

if you really want to know the difference between "options" and "arguments" i can give you my ex-wifes phone number...im betting she would love to give ya an earful of the difference...lol...lol...DAMIEN
Locked

Return to “Other topics”