passing parameters to functions in shell script
Hi guys, I know we can write fucntions in shell script and call them with the following syntax:
function-name () { command1 command2 .... .... } and to call it we just give the command: fucntion-name. Now, can we pass parameters to functions by name/value just as we do it in C language? If yes, then How do we do that? Thanks |
Hi,
Bash (ksh) isn't that strickt when it comes to functions. Unless specifically set, variables are also known inside functions. Using $1, $2 etc also works. Code:
#!/bin/bash Hope this helps. |
All times are GMT -5. The time now is 12:58 AM. |