This will create a new file named t whose contents is the word "test":
$ echo "test" > t
more will display the contents of the file:
$ more t
cat reads the contents of /dev/null (which contains nothing) and > writes this into t$ cat /dev/null > t
The next time you open your file its contents will be empty. Windows users take notice -- when you run the command "cat /dev/null" Windows will throw an error. However, it will still successfully empty the contents of your file.$ echo "test" > t
more will display the contents of the file:
$ more t
cat reads the contents of /dev/null (which contains nothing) and > writes this into t$ cat /dev/null > t
Delete the Contents of a File without Removing and Recreating It [hackaddict.net]
</img>
More...