How to pass position parameter into function.?

Hi Gurus,

I have request which needs to pass position parameter to a function. I tried below simple code, it doesn't work.

#!/bin/bash
func_1(){
echo $1
}

func_1
$ ./set_file abc

$

do I need add some to get the position para first?

thanks in advance.

Try:

#!/bin/bash
func_1(){
echo $1
}

func_1 $1
1 Like

Thanks bartus11

this code works

use "$@" to pass along every parameter

1 Like