Skip to main content

Why is $1 in a function not printing the script's first argument?

Why echo $1 doesn't print $1 in this simple bash script?

#!/bin/bash
# function.sh
print_something () {
echo $1
}
print_something

$ ./function.sh 123  -> why does not print '123' as result?
pietro letti
  • 429
  • 1
  • 5
  • 11