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

Forum

Truncate file witho...
 

Truncate file without deleting the file  


Alan
Posts: 35
 Alan
(@alan)
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
admin
Posts: 93
Admin
(@mjv119gmail-com)
Member
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.

Reply

Leave a reply


 
Preview 0 Revisions Saved
Share:

Please Login or Register