What output will echo > produce?

后端 未结 2 1260
無奈伤痛
無奈伤痛 2021-01-23 11:16

I don\'t have a linux at hand and instead use compileonline.com to check out some code in bash, yet I\'m new to bash. Could somebody give a hand?

for var
do echo         


        
相关标签:
2条回答
  • 2021-01-23 11:40

    > always overwrites.

    Writing a new line would be achieved by using the “append” redirection operator >>.

    0 讨论(0)
  • 2021-01-23 11:45

    It overwrites the file each time

    $ cat script.sh 
    for var in 123 abv xyz
    do
        echo $var > fniz
        cat fniz
    done
    $ ./script.sh 
    123
    abv
    xyz
    

    If you want to append, use >>

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