The example below does not work: ~/test is empty.
foreach i (`ls`)
foreach echo $i > ~/test
foreach end
As well this does not work (unlike bash):
foreach i (`ls`)
foreach echo $i
foreach end > ~/test
The example below does not work: ~/test is empty.
foreach i (`ls`)
foreach echo $i > ~/test
foreach end
As well this does not work (unlike bash):
foreach i (`ls`)
foreach echo $i
foreach end > ~/test
Workaround is to use addition '>>' on every turn of the loop, like this:
foreach i (`ls`)
echo $i >> ~/test
end
foreach line? foreach is putting the result of ls in the variable i (line by line), and as such there should be no output. And even if there was some output, you would be redirecting it, not copying it, so the echo $i would not print echo anything. This is not a "workaround", this is exactly how it should behave.
– ChatterOne
Jan 02 '19 at 09:26