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*

6
  • 72
    Very good answer although it would be much better if it were broken into functions. Commented Sep 30, 2016 at 11:40
  • 1
    Maybe add that functions allow you to import that script into another script (by using source or . scriptname.sh, and use those functions as-if they were in your new script. Commented Sep 30, 2016 at 21:37
  • That's already covered in another answer. Commented Sep 30, 2016 at 21:40
  • 1
    I appreciate that. But I'd rather let other people be important as well. Commented Sep 30, 2016 at 22:00
  • 7
    I faced a case today where I had to redirect some of the output of a script to a file (to sent it via email) instead of echoing. I simply had to do myFunction >> myFile to redirect the output of the desired functions. Pretty convenient. Might be relevant. Commented Sep 30, 2016 at 23:28