I am new to Linux. There is something that is unclear to me.What is the difference between echo  > logfile and > logfile ? When I run the first one, the logfile size doesn't become zero and same name file will be created with 1 byte size. For the second one, logfile size will become zero and same name file will be created with 0 byte size.In what situations should the commands be used differently?For me, I use it when I want to free up the log files.
differences between echo> and > command
shell;io redirection;echo
They do essentially the same thing. You're seeing a file size difference because echo includes a newline at the end, which takes up a byte. You can stop it with -n, so echo -n  > logfile will result in a 0-byte file