Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    Works for me... I use full syntax for functions though "function bla() { echo $1; }", can't make short one into a one liner. Not sure it makes a difference. What version of bash? Commented Dec 30, 2009 at 23:28
  • 16
    try echo "$@" or for i in "$@"; do echo $i ; done for using correctly quoted parameters containing spaces. This is the very clearly mentioned in all bash documentation under positional parameters section. Commented Jun 14, 2013 at 7:06
  • 2
    I was having a similar problem, trying to pass one quoted string as a parameter and only the first word of the string being recognized as part of the parameter. Samveen's suggestion to change $1 to $@ worked for me. Note that I was only passing one parameter to the function, but if I'd been passing more using the for statement would have been necessary. Commented Apr 20, 2014 at 8:01
  • 1
    See also stackoverflow.com/questions/10067266/… Commented Feb 8, 2017 at 4:31
  • 3
    try myFunction "$@" Commented Sep 22, 2017 at 6:03