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*

9
  • Thanks for your explanation in detail! It's very clear and I'm understanding clearly! Commented Sep 4 at 3:47
  • FYI, some essential reading about while read loops: Why is using a shell loop to process text considered bad practice? and Understanding "IFS= read -r line" Commented Sep 4 at 4:18
  • Why is my variable local in one 'while read' loop, but not in another seemingly similar loop? has information on making that whatever | while ... work. Commented Sep 4 at 6:50
  • The idea of "${array[@]}" is to have the array elements as distinct args, so that e.g. ls "${filenames[@]}" works for an arbitrary list of filenames, even with whitespace. But the shell can also join them into a string, just use "${array[*]}" instead. Commented Sep 4 at 6:53
  • @ilkkachu [*] instead of [@] - yeah, that's true, that would work. I guess I think too much in perl-ish terms when it comes to working with arrays and lists. And bash really does need a proper join function. So does awk, for that matter. It's so essential a feature it should be built-in. Commented Sep 4 at 7:00