Bash Question

How to pass an integer as an argument in Shell function and retrieve it

I have a small function like this -

#! /bin/sh
function hey() {
echo $a

hey x

As per my understanding it should print
but it is printing
. How to resolve it?

Answer Source

Running you code in my bash (not sh) , it also prints x. But if i change the last line to

hey $x 

then it prints 2.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download