The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

LinkBacks (?)
LinkBack to this Thread: http://www.unix.com/unix-advanced-expert-users/45230-command-similar-touch-modify-file-size.html
Posted By For Type Date
yoga_sawant's Bookmarks on Delicious This thread Refback 12-25-2008 09:44 AM

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 7 04-28-2009 03:08 AM
Can I make "touch" create executable files by manipulating umask? tphyahoo Shell Programming and Scripting 2 01-30-2009 04:20 PM
Maximum input file size in "Diff" Command Neeraja UNIX for Dummies Questions & Answers 1 01-17-2007 10:09 AM
Strange "TOUCH" problem budrito UNIX for Advanced & Expert Users 3 10-29-2005 09:34 AM
Command for "Resident memory Size" Cristobal Perez UNIX for Dummies Questions & Answers 1 06-07-2002 08:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack (1) Thread Tools Search this Thread Rate Thread Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 11-14-2007
sriharshareddyk sriharshareddyk is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 1
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
  #2 (permalink)  
Old 11-14-2007
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
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)
  #3 (permalink)  
Old 11-14-2007
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
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
  #4 (permalink)  
Old 11-15-2007
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
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
Closed Thread

Bookmarks

Tags
touch

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0