Posts

Showing posts from January 3, 2019

Iterating over files in Bash and obtaining the index and the counts

Image
2 The proper way to iterate over files in a directory in Bash is using "for loop" and glob as following: for f in *.jpg; do echo "- Processing file: $f" done But how can I retrieve the total count of the files and the current index of the loop interaction? I need the total count, not the cumulative count to show the progress. shell-script share | improve this question edited 4 hours ago asked 5 hours ago bman 130 1 9