Skip to main content

Why doesn't 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 doesdoesn't notit print '123' as a result?

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?

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

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

$ ./function.sh 123  -> why doesn't it print '123' as a result?

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

Tweeted twitter.com/StackUnix/status/1034138877471203329
edited title
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117
Loading
added 62 characters in body; edited title
Source Link
Rui F Ribeiro
  • 57.9k
  • 28
  • 156
  • 237
Loading
added 32 characters in body
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117
Loading
Source Link
pietro letti
  • 429
  • 1
  • 5
  • 11
Loading