You can write functions in the shell script. And inside of them, you can write the logic for iterations (loops) or any other code. The tricky question is what happens when you give duplicate names in the script. It is applicable for both BASH and KSH (Korn shell).
Script with Duplicate Function Names
The iterate() is a duplicate function. It ignores first function. it considers only last duplicate function.
How it Works – see the full explanation
Here I have given two functions of iterate(). In the first iterate function, just I have given echo statement. Anyways, it will be skipped.
In the second iterate function, the variable arg1 holds first value of input supplied. The shift operator shifts the input values to left side.
The result after execution, display the shifted values. The supplied input for the function is ‘ a b c d e ‘
Video – Result of the script
Comments are closed.