UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old September 29th, 2004, 02:36 PM
crazyh0rse crazyh0rse is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 crazyh0rse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile create file for a desired file size.

Hello all.

This is my first post here.
I'm not an unix guy so please bear with me. At work, from time to time I get the need to have some 'junk' files of varying sizes. Typically, I write a small 'script' which cats a file to another file. I run this manually until it reaches closer to a desired size.

My question: Is there a better way to create a file which comes to the exact size as specified. Please give me pointers. I have to write this in Aix environment. Thanks a lot in advance!

Reply With Quote
  #2  
Old September 29th, 2004, 04:05 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 49 m 57 sec
Reputation Power: 9
q1: what's a junk file ?
q2: 4 what you need a junk file ?
q3: did you try: man mkfile ?

Reply With Quote
  #3  
Old September 29th, 2004, 07:41 PM
fpmurphy fpmurphy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 257 fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 23 h 46 sec
Reputation Power: 6
Yes and no. What you are doing is fairly common for pure
shell script programming. A more efficient way is to write
a small C program to create a file of the exact size that
you want i.e.

mkemptyfile <filename> <size>

Another way is to use /dev/zero in conjunction with the dd utility i..e.

dd if=/dev/zero of=filename bs=1024 count=20

creates the zeroized file "filename" of size 20K.

Last edited by fpmurphy : September 29th, 2004 at 07:55 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > create file for a desired file size.


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway