Support & Downloads

Quisque actraqum nunc no dolor sit ametaugue dolor. Lorem ipsum dolor sit amet, consyect etur adipiscing elit.

s f

Contact Info
198 West 21th Street, Suite 721
New York, NY 10010
[email protected]
+88 (0) 101 0000 000
Follow Us


Truncate file witho...

Truncate file without deleting the file  

Posts: 35
Eminent Member
Joined: 4 months ago

I want to write a shell script in which the file will be truncated if there is any unknown data found. Any option to truncate the UNIX file or variable instead of deleting the original file?

1 Reply
Posts: 93
Joined: 5 years ago

Try this:

cp /dev/null filename

/dev/null is an empty file which is present in all the UNIX and LINUX machines.
Copying this file will overwrite the content of the original file and make it empty.

cat /dev/null > filename

This command also does the same job.


Leave a reply

Preview 0 Revisions Saved

Please Login or Register