What is the use case of noop [:] in bash?

后端 未结 12 947
滥情空心
滥情空心 2020-12-12 13:07

I searched for noop in bash (:), but was not able to find any good information. What is the exact purpose or use case of this operator?

I tried following and it\'s w

12条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 13:15

    One use is as multiline comments, or to comment out part of your code for testing purposes by using it in conjunction with a here file.

    : << 'EOF'
    
    This part of the script is a commented out
    
    EOF
    

    Don't forget to use quotes around EOF so that any code inside doesn't get evaluated, like $(foo). It also might be worth using an intuitive terminator name like NOTES, SCRATCHPAD, or TODO.

提交回复
热议问题