LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   truncate command (http://www.linuxquestions.org/questions/linux-general-1/truncate-command-20871/)

butthead 05-13-2002 04:11 PM

truncate command
 
I need to add the truncate command to a script to truncate a file's contents to nothing. The man pages on this topic don't clearly reveal the appropriate syntax to use.

I have a file named /var/tmp/junk from which I want to remove all contents. So my script stats out like this...
#include <unistd.h>
int truncate(*** /var/tmp/junk *** 0)

I don't know how to fill in the missing parameters.

HELP!!!!

acid_kewpie 05-14-2002 03:40 AM

you keep mentioning script... do you mean script or c? truncate is a C function, not a script command.

but you'd probably want

char *file = "var/tmp/junk";
truncate ( file, 0);

but erm... you seem to have just blindly copied it from the manpage... what you have there is a header reference, nothing usable in the slightest... maybe you should be reading a few more manuals? :D

and this kind of thing should be in the programming forum.


All times are GMT -5. The time now is 07:33 AM.