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*

2
  • This seems to work: nrofjpg=$( grep -c '\.jpg$' <<< ${FILES[*]} ) The grep -c in your comment was the key it seems Commented Apr 15, 2022 at 18:34
  • @Nemdr, <<< ${FILES[*]} feeds the concatenation of the elements of the array with the first character of $IFS to grep -c (or worse in older versions of bash where that was subject to splitting before joining). So unless you have run IFS=$'\n' or some file names contain newline characters, grep will only get one line of input. And again, as I said that won't work properly if file names contain newline characters. Commented Apr 15, 2022 at 18:40