- In which two ways can we define a function?
- name() {
} - function name {
}
- name() {
- What are some advantages of functions?
- Easy to reuse code
- Facilitates code sharing
- Abstracting complex code
- What is the difference between a globally scoped variable and a locally scoped one?
Locally scoped variables are only valid within a function, globally scoped variables can be used throughout the entire script (even in functions). - How can we set values and attributes on variables?
By using the declare command. - How can a function use arguments passed to it?
In the same way as a script can: by using $1, $#, $@, and so on. - How can we return a value from a function?
By outputting it to stdout. The command that calls the function should know to capture the output, using command substitution. - What does the source command do?
It executes commands from a file in the current shell. If the sourced...
United States
Great Britain
India
Germany
France
Canada
Russia
Spain
Brazil
Australia
Singapore
Hungary
Ukraine
Luxembourg
Estonia
Lithuania
South Korea
Turkey
Switzerland
Colombia
Taiwan
Chile
Norway
Ecuador
Indonesia
New Zealand
Cyprus
Denmark
Finland
Poland
Malta
Czechia
Austria
Sweden
Italy
Egypt
Belgium
Portugal
Slovenia
Ireland
Romania
Greece
Argentina
Netherlands
Bulgaria
Latvia
South Africa
Malaysia
Japan
Slovakia
Philippines
Mexico
Thailand