For loop in Cygwin bash shell followed by “>”

前端 未结 2 624
日久生厌
日久生厌 2021-01-15 20:59

When I type the following command in a cygwin bash shell:

for i in $(ls) do echo $i done

I get a \">\" asking me to keep typing, as opposed

相关标签:
2条回答
  • 2021-01-15 21:30

    You need to separate your for, do and done statements.. Try this:

    for i in $(ls); do echo $i; done
    

    You can also separate the statements with newlines. For exmaple:

    cygwin$ for i in $(ls)
    > do
    > echo $i
    > done
    
    0 讨论(0)
  • 2021-01-15 21:36

    Your for loop is still waiting for the semicolon or newline that terminates the list of values. So far, your loop with set i to the list of words produced by ls, the word do, the word echo, the words produced by the expansion of the current value of i, and the word done.

    The > is the so-called secondary prompt, which indicates that the shell is still waiting for input to complete the command started by for.

    0 讨论(0)
提交回复
热议问题