Clean up a file

Posted on Aug 1, 2024
echo -n > logfile
  • the -n flag instructs echo command not to append a new line.
cat /dev/null > logfile
  • the : character is a null command.
: > logfile
sudo sh -c ': > logfile'
: | tee logfile
: | sudo tee logfile
> logfile
sudo sh -c '> logfile'
truncate -s 0 logfile