Timeline for Command substitution in for loop not working
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 13, 2017 at 12:36 | history | edited | CommunityBot | replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/ | |
| Aug 27, 2013 at 13:04 | history | edited | Stéphane Chazelas | CC BY-SA 3.0 | added 90 characters in body |
| Aug 27, 2013 at 9:46 | comment | added | mike | Oh, of course. That makes totally sense considering the debug output. | |
| Aug 27, 2013 at 9:41 | comment | added | Stéphane Chazelas | @mike, no, the wildcards (as added by ls -F) got expanded upon the command substitution ($(...)). If there had been a file called scala*, that wildcard would also have been expanded upon the expansion of $f (and you'd had seen all the filenames starting with scala separated by spaces on one line) | |
| Aug 27, 2013 at 9:05 | vote | accept | mike | ||
| Aug 27, 2013 at 9:05 | comment | added | mike | Okay, quite a few things I should improve. But to get it straight. The loop did not fail per se. The grep did work, but because of the * added by ls -F the variable f in $f got expanded. So either stop the expansion or remove the F flag from the ls command. The opposite command, i. e. without the v flag in grep, did work, because there was nothing to expand a file name matching <filename>.bat* to. | |
| Aug 26, 2013 at 19:50 | history | edited | Stéphane Chazelas | CC BY-SA 3.0 | added 233 characters in body |
| Aug 26, 2013 at 17:43 | history | answered | Stéphane Chazelas | CC BY-SA 3.0 |