LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-13-2002, 04:11 PM   #1
butthead
LQ Newbie
 
Registered: Nov 2001
Location: Guilderland, NY
Distribution: SuSe 8.1
Posts: 13

Rep: Reputation: 0
Exclamation 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!!!!
 
Old 05-14-2002, 03:40 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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?

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Truncate A File Dovetails Linux - Newbie 2 10-22-2005 06:58 PM
truncate lines with c alaios Programming 17 08-25-2005 08:51 AM
truncate the first character alaios Linux - General 1 02-10-2005 04:55 AM
Should I truncate an inode? akurtis Red Hat 0 08-02-2004 09:34 PM
how to use truncate sureshbabu Linux - Newbie 1 10-29-2003 04:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration