Empty or Delete a Large File Content on Linux

Tips of Linux

Empty File Content by Redirecting to Null

# > access.log

Empty File Using ‘true’ Command Redirection

# : > access.log

# true > access.log

Empty File Using cat/cp/dd utilities with /dev/null

# cat /dev/null > access.log

# cp /dev/null access.log

# dd if=/dev/null of=access.log

Empty File Using echo Command

# echo "" > access.log

# echo -n "" > access.log

# echo > access.log

Empty File Using truncate Command

# truncate -s 0 access.log
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus