Empty or Delete a Large File Content on Linux

Tips of Linux

Empty File Content by Redirecting to Null

1
# > access.log

Empty File Using ‘true’ Command Redirection

1
2
3
# : > access.log

# true > access.log

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

1
2
3
4
5
# cat /dev/null > access.log

# cp /dev/null access.log

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

Empty File Using echo Command

1
2
3
4
5
# echo "" > access.log

# echo -n "" > access.log

# echo > access.log

Empty File Using truncate Command

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