Is there any differences between “: > file” and “> file”?
$ : > file.out
$ ls -l file.out
-rw-rw---- 1 user user 0 Mar 18 21:08 file.out
$ > file.out
$ ls -l file.out
-rw-rw---- 1 user user 0 Mar 18 21:08 file.out
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
:is the shell built-in NO-OP or null operation. So yeah, directing it to a file ends up with an empty file, as does directing nothing to a file. There’s a sense, I suppose, in which your source is a different kind of nothing, but the result is the same. According to the advanced Bash scripting guide, the “> file.out” formulation won’t work on some systems.Note that in both cases (unlike “touch”) the file contents will be replaced with nothing if the file already exists.