question about files?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers question about files?
# 1  
Old 12-09-2003
question about files?

I was at a vendor demonstration last week, and the presenter had his laptop on screen where we could see the product demo. He had a Unix terminal screen up and created an empty file, but he used some command (I wish I had caught how he did this) to actually make the empty file a certain size. Does anyone know how this is accomplished? In this instance, he used it to show how a 20 Mb file would be transferred through a router.


Anyone know how this was possibly done?
# 2  
Old 12-09-2003
i think the 'dd' command can do this with the bs=BYTES, obs=BYTES, and of=FILE arguments.
# 3  
Old 12-09-2003
Some systems have a prealloc command. HP-UX does, SunOS does not. So it's not universal.
# 4  
Old 12-09-2003
Quote:
Originally posted by norsk hedensk
i think the 'dd' command can do this with the bs=BYTES, obs=BYTES, and of=FILE arguments.
I think the trick is to produce the file, say 20MB, without a 20MB input file. Off hand, I can't do this with dd. I tried to cat /dev/null into dd, i.e.

Code:
cat /dev/null | dd of=test.file bs=20480000 (well almost!)

but this will not work because nothing comes in dd to count Smilie

If I had a 20MB file, I could pipe that into dd, but then if I had a 20MB file, what's the point? Smilie
# 5  
Old 12-09-2003
Some systems have a /dev/zero that produces a infinite number of zeros. Or a /dev/full that produces a infinite amount of garbage. You need to use something like that.
# 6  
Old 12-09-2003
Perfect, something like:

Code:
cat /dev/zero | dd of=test.file bs=20000

Thanks!

Not sure how to make 20MBs from this Smilie Perhaps someone can assist? I tried bs=20000 but it was HUGH!!! Much bigger than 20MB!!!!

Neo
# 7  
Old 12-09-2003
what about a while() loop?
something like:
Code:
while ($filesize != 2000000)
{cat somefile of a managable size  > newfile}

now this dosnt create a file out of nothing, but put inside of a small script, well theres your arbitrary file size creation utility.


EDIT: didnt see perderabos and neos follow up posts, so maybe you could 'cat /dev/zero' in a while loop...

Last edited by norsk hedensk; 12-10-2003 at 12:00 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Question on awk source files

Im repeating same command to get count, filename from 4 different files, writing to one same file. awk 'END{print NR"|"FILENAME}' file.txt >> temp.txt; awk 'END{print NR"|"FILENAME}' asdf.txt >> temp.txt; awk 'END{print NR"|"FILENAME}' lkjh.txt >> temp.txt; awk 'END{print NR"|"FILENAME}'... (12 Replies)
Discussion started by: JSKOBS
12 Replies

2. Shell Programming and Scripting

Bash Looking into files question

I have a bunch of files that are messages in my directory. Each message has a date located in the file. How can I look into each file and find the date? Thank you for any help (7 Replies)
Discussion started by: totoro125
7 Replies

3. Shell Programming and Scripting

Bash script deleting my files, and editing files in subdirectories question

#!/bin/bash # name=$1 type=$2 number=1 for file in ./** do if then filenumber=00$number elif then filenumber=0$number fi tempname="$name""$filenumber"."$type" if (4 Replies)
Discussion started by: TheGreatGizmo
4 Replies

4. Solaris

Question about copying files in Solaris

Hi everyone, What is the Solaris equivalent of cp -u? I'm copying files from one directory to another, and I'd like to only copy files which are newer. Thanks! (4 Replies)
Discussion started by: Fatbob
4 Replies

5. UNIX for Dummies Questions & Answers

Please help Question about Excel Files and Unix

Hello I have an excel file , it has 4 tabs , each having specific details for example it has a customer tab , it has a payments tab and it has an address tab Question is How do I seperate each of these tabs and load them into 3 different excel files Using Unix That is the... (2 Replies)
Discussion started by: arnab1978
2 Replies

6. Shell Programming and Scripting

Simple bash question - 2 files together

Hello Friends, I have a simple problem but I can't seem to find a solution, perhaps you could gimme a hand here.. I have to files 1.txt which contains the following 00 01 02 03 and 2.txt which contains the following: 20 21 22 23 All I need is to concatenate these 2 files in... (2 Replies)
Discussion started by: bashshadow1979
2 Replies

7. Shell Programming and Scripting

question using grep with files

hi, i'm trying to figure out how to use grep in different ways in bash.. lets say you have two files, one with a list of words and the other with text i want to go through the list of words in one file and for each word, find every occurrence of that word in the other file and display... (1 Reply)
Discussion started by: kratos.
1 Replies

8. UNIX for Dummies Questions & Answers

listing files question

hello im new to linux programming trying to list files in a directory i current have the code to list all the files but i do not want the hidden files to show such as a file named .openoffice.org2.0 for example, can anyone help me or point me in the right direction #include <sys/types.h>... (2 Replies)
Discussion started by: Fortune
2 Replies

9. Shell Programming and Scripting

Compare files question

Hi all, How do I compare contents of entire two files except for the first line is each of them? I am sure first lines from both my files are going to be different so I want to ignore them. Is there a easier way than creating temporary files by cutting out the first line and then comparing... (1 Reply)
Discussion started by: jakSun8
1 Replies

10. UNIX for Dummies Questions & Answers

Question: Removing Files Using du

I want to identify files that have zero length, bascially files that are 0 byte in size. Then remove those files that are found using du. I wanted to do this in a way that, let's remove 0 size jpg files: foreach f (*jpg) du $f end This will only list the size and file name, I wanted... (4 Replies)
Discussion started by: ApprentiSorcier
4 Replies
Login or Register to Ask a Question