DEV Community

Ali Reza
Ali Reza

Posted on

Clean all log file with one command

Find

this command search for files in a directory hierarchy.

exec switch

This switch can execute the command for each item found.

tee

read from standard input and write to standard output and files.
now pass {} \; </dev/null to this command to remove each content from file .

find  / -type f -name "*.log" -exec tee {} \; </dev/null
Enter fullscreen mode Exit fullscreen mode

Top comments (0)