What is the purpose of the : (colon) GNU Bash builtin?

前端 未结 12 860
梦如初夏
梦如初夏 2020-11-22 14:01

What is the purpose of a command that does nothing, being little more than a comment leader, but is actually a shell builtin in and of itself?

It\'s slower than inse

12条回答
  •  一生所求
    2020-11-22 14:12

    You could use it in conjunction with backticks (``) to execute a command without displaying its output, like this:

    : `some_command`
    

    Of course you could just do some_command > /dev/null, but the :-version is somewhat shorter.

    That being said I wouldn't recommend actually doing that as it would just confuse people. It just came to mind as a possible use-case.

提交回复
热议问题