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*

7
  • 1
    You may want to try using an array. This should explain how to use a bash array with elements that have spaces in them and how to iterate over the array: stackoverflow.com/questions/9084257/… Commented Apr 8, 2021 at 16:16
  • 3
    Please edit your question and clarify how files will be populated. Will it be all arguments? Some? A command line option? Also, this is almost certainly a dupe of Why does my shell script choke on whitespace or other special characters?. Does it answer your question? Commented Apr 8, 2021 at 16:26
  • mywiki.wooledge.org/BashFAQ/050 Commented Apr 8, 2021 at 16:33
  • Your last code snipped: It makes no sense to use getopts in this script if you only have a single option that signals "use these files". The script could just loop over "$@" to process the files. Commented Apr 8, 2021 at 17:14
  • 1
    @PedroSiqueira Is the -i option the only one that takes what amounts to multiple values? Commented Apr 8, 2021 at 17:38