The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
"sed" to check file size & echo " " to destination file jockey007 Shell Programming and Scripting 6 11-13-2007 05:00 PM
Maximum input file size in "Diff" Command Neeraja UNIX for Dummies Questions & Answers 1 01-17-2007 06:09 AM
Can I make "touch" create executable files by manipulating umask? tphyahoo Shell Programming and Scripting 1 06-07-2006 12:23 PM
Strange "TOUCH" problem budrito UNIX for Advanced & Expert Users 3 10-29-2005 05:34 AM
Command for "Resident memory Size" Cristobal Perez UNIX for Dummies Questions & Answers 1 06-07-2002 04:11 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-14-2007
Registered User
 

Join Date: Aug 2007
Posts: 1
Stumble this Post!
Thumbs up Command similar to "touch" for modify File size

Hi All,
I'm trying to find a command like similar to "touch" which would let me change the file size property.
For ex: I have a file of size 1MB using the command i would like to set/update the size something like 1KB.
Is it possible? Is there any such command which would accomplish this task for me? Kindly suggest.

Regards,
Harsha
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-14-2007
Yogesh Sawant's Avatar
Part Time Moderator and Full Time Dad
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 767
Stumble this Post!
if you are not concerned about the contents of file, overwrite the file (of 1 MB in your case) with a different file having the required size (1KB in your case)
Reply With Quote
  #3 (permalink)  
Old 11-14-2007
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,099
Stumble this Post!
Exactly, Yogesh.

To expand a bit on this: if you want to keep the inode number, but don't care about the content use dd:

dd if=/dev/zero of=/your/file bs=<nr of bytes the file should have> count=1

bakunin
Reply With Quote
  #4 (permalink)  
Old 11-14-2007
Yogesh Sawant's Avatar
Part Time Moderator and Full Time Dad
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 767
Stumble this Post!
this helps to change the size of a file to 1 KB:
Code:
dd if=/dev/zero of=hollow_and_empty bs=1024 count=1
dd --help for more info
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
touch

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0