Timeline for bash iterate file list, except when empty
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 26, 2024 at 13:01 | comment | added | chepner | shopt -u nullglob after the loop. | |
| May 25, 2024 at 16:33 | comment | added | phil294 | Note that this comes with an annoying downside outside of for loops: If for example in your current dir there are NO .txt files, a simple ls *.txt will now fall back to ls thus list ALL files of the directory. | |
| Aug 3, 2022 at 9:34 | review | Suggested edits | |||
| Aug 3, 2022 at 12:12 | |||||
| Sep 2, 2017 at 12:55 | comment | added | chepner | @koppor It sounds like you aren't actually using bash. | |
| Sep 2, 2017 at 12:24 | comment | added | koppor | shopt -s nullglob did not work for me on Ubuntu 17.04, but [ -f "$fname" ] || continue worked well. | |
| Nov 9, 2016 at 15:12 | history | edited | Stéphane Chazelas | CC BY-SA 3.0 | avoid echo, you can't `break` as some of the zip files may be non-regular ones. [ -f ] would return false for non-regular files |
| Nov 2, 2015 at 11:27 | vote | accept | symcbean | ||
| Oct 31, 2015 at 19:04 | history | answered | chepner | CC BY-SA 3.0 |