- Why are flags often used as modifiers whereas positional parameters are used as targets?
Flags often modify the behavior: it can make a script more or less verbose, or perhaps write the output somewhere. Often, a command manipulates a file, which is then considered the primary target for what the command actually tries to achieve. - Why do we run getopts in a while loop?
All flags are parsed sequentially, and when getopts can no longer find new flags it will return an exit code different from 0, which will exit the while loop at exactly the right moment. - Why do we need a ?) in the case statement?
We cannot trust the user to correctly use all flags all the time. ?) matches any flag we have not specified, which we can then use to inform the user of incorrect usage. - Why do we (sometimes) need a :) in the case statement?
The :) is used when the optstring specifies an argument...
United States
United Kingdom
India
Germany
France
Canada
Russia
Spain
Brazil
Australia
Argentina
Austria
Belgium
Bulgaria
Chile
Colombia
Cyprus
Czechia
Denmark
Ecuador
Egypt
Estonia
Finland
Greece
Hungary
Indonesia
Ireland
Italy
Japan
Latvia
Lithuania
Luxembourg
Malaysia
Malta
Mexico
Netherlands
New Zealand
Norway
Philippines
Poland
Portugal
Romania
Singapore
Slovakia
Slovenia
South Africa
South Korea
Sweden
Switzerland
Taiwan
Thailand
Turkey
Ukraine