![delete zero byte file in unix delete zero byte file in unix](https://www.pythonpool.com/wp-content/uploads/2020/02/Capture-26.jpg)
In Linux, the null device is basically utilized for discarding of unwanted output streams of a process, or else as a suitable empty file for input streams. Empty File Using cat/cp/dd utilities with /dev/null Here we will use a symbol : is a shell built-in command that is essence equivalent to the true command and it can be used as a no-op (no operation).Īnother method is to redirect the output of : or true built-in command to the file like so: # : > access.logĮmpty Large File Using Linux Commands 3. Empty File Using ‘true’ Command Redirection Empty File Content by Redirecting to NullĪ easiest way to empty or blank a file content using shell redirect null (non-existent object) to the file as below: # > access.logĮmpty Large File Using Null Redirect in Linux 2. Important: For the purpose of this article, we’ve used file access.log in the following examples. With that said, below are means of clearing file content from the command line.
![delete zero byte file in unix delete zero byte file in unix](https://g6k7x4j6.stackpathcdn.com/wp-content/uploads/2021/09/Recover-the-deleted-files-using-Foremost-command.jpg)
Clearing the content of a critical system or configuration file could lead to a fatal application/system error or failure. How can this be achieved? In this article, we will go through several different ways of emptying file content with the help of some useful commands.Ĭaution: Before we proceed to looking at the various ways, note that because in Linux everything is a file, you must always make sure that the file(s) you are emptying are not important user or system files. Occasionally, while dealing with files in Linux terminal, you may want to clear the content of a file without necessarily opening it using any Linux command line editors.