- 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
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