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.

7
  • thanks, but isn't function copyFiles{…} a correct syntax? Though i am a new bie i run some program successfully with the syntax. Commented Sep 15, 2015 at 11:11
  • 2
    Valid variants are copyFiles {…} and copyFiles(){…} and copyFiles() {…}, but not copyFiles{…}. Note the space in the variant without ()
    – A.B.
    Commented Sep 15, 2015 at 11:14
  • 1
    among the variants, there's copyFiles() { ... } without a function keyword. Added benefit : also valid in POSIX (unix.stackexchange.com/questions/73750/…)
    – YoungFrog
    Commented Mar 28, 2020 at 11:04
  • 1
    In this particular case you can do for i; do ...; done to iterate over $@. Also, this wasn't asked, but if you need to pass a couple of arrays, you probably want to pass by reference.
    – x-yuri
    Commented Jan 12, 2021 at 19:18
  • Shebang is spelled without the dash. Commented Aug 30, 2021 at 7:11