1837191 Members
2745 Online
110114 Solutions
New Discussion

Re: unix command

 
SOLVED
Go to solution
Tony Willis_1
Frequent Advisor

unix command

how to create a file for certain size, example 100mb file from unix prompt
"Not Today,Nice Try, Next Time"
6 REPLIES 6
harry d brown jr
Honored Contributor

Re: unix command

how about a file full of zeroes?

dd if=/dev/zero of=/somefilepath bs=1k count=100000

live free or die
harry
Live Free or Die
harry d brown jr
Honored Contributor

Re: unix command



/dev/zero, if it doesn't exist on your system looks like this:

# ls -l /dev/zero
crw-rw-rw- 1 bin sys 3 0x000004 Aug 13 2001 /dev/zero
#


mknod /dev/zero c 3 4


live free or die
harry
Live Free or Die
H.Merijn Brand (procura
Honored Contributor

Re: unix command

d3:/tmp 115 > rm xx
d3:/tmp 116 > ls -l xx
ls: xx: No such file or directory
d3:/tmp 117 > perl -e 'open XX,">xx";truncate XX,100*1024*1024'
d3:/tmp 118 > ls -l xx
-rw-rw-rw- 1 merijn softwr 104857600 Aug 21 21:16 xx
d3:/tmp 119 >
Enjoy, Have FUN! H.Merijn
keith persons
Valued Contributor
Solution

Re: unix command

you can also use the prealloc(1) command to preallocate space on a disk. One caveat tho is the file will revert to actual disk space used if it isn't fully populated on the first open. i.e. prealloc filename 1000 then edit file and place only 50 bytes in file - on close it will no longer be size 1000 but 50.

hope this is clear, let me know if you're confused at all.
Tom Danzig
Honored Contributor

Re: unix command

prealloc filename 100000
Tony Willis_1
Frequent Advisor

Re: unix command

thanks for all the answers. prealloc command is the easiest solution in our situation
"Not Today,Nice Try, Next Time"