Visit The New, Modern Unix Linux Community

creating file of 1MB using shell command?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting creating file of 1MB using shell command?
# 1  
creating file of 1MB using shell command?

Hi everybody in the forum,

I want to create an empty file of say some 1MB ,i mean at the command line itself.How is this possible??????EEK!
# 2  
Try this.

dd if=/dev/zero of=output.file bs=1024 count=1024

It will be filled with /dev/zero's
# 3  
Explaination clearly....

Hi Thanks for the reply....
I would like to be explained in detail
# 4  
Look into man dd. Or better yet info dd
# 5  
Originally Posted by vino
Try this.

dd if=/dev/zero of=output.file bs=1024 count=1024

It will be filled with /dev/zero's
this is just a suggestion,
when generating files of huge size,
it is better you attack from the block size thereby reducing the count

for a 1 MB file,
dd if=/dev/zero of=output.file bs=1024 count=1024

time taken = 0.13 s
dd if=/dev/zero of=output.file bs=1048576 count=1

time taken = 0.08 s
it is just a difference of (0.13 - 0.08) s

but consider generating some 200 MB files
attacking block size would surely provide a difference.

Last edited by Yogesh Sawant; 02-26-2010 at 02:39 PM.. Reason: added code tags

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #886
Difficulty: Medium
Phishing is the attempt to acquire sensitive information such as usernames, passwords, and credit card details directly from users by installing backdoors to operating systems.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating an excel file with filters using shell script.

Hi All, I am new to shell scripting. I have made a script that can convert an excel file from cvs file. This excel file contains hundreds of records and i would like the reader to be able to filter. Is it possible to create an excel file with filters? or that functionality has not been... (3 Replies)
Discussion started by: Marvin159875321
3 Replies

2. UNIX for Beginners Questions & Answers

Creating file and passing argument to a command

Hi All, I am having command to run which will take argument as input file. Right now we are creating the input file by cat and executing the command ftptransfer -i input file cat >input file file1 file2 cntrl +d Is there a way I can do that in a single command like ... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

3. Shell Programming and Scripting

Shell Scripting for creating ftp and transfer file

Dear All, We run backup script to update backup file every hour. I want to create a script, which transfer these files in another server using ftp as new backup file created every hour. Files should be stored with a unique name for every hour(e.g 20130708_13:00 , 20130708_14:00 and so on) and... (13 Replies)
Discussion started by: Preeti Saini
13 Replies

4. UNIX Desktop Questions & Answers

creating an executable file from shell scripts

Hi Friends, I have a shell script which does some operations etc, would it be possible to create an executable file out from this shell script? meaning the executable file is not editable, thus the source code will not be visible to other users for copyright reasons. Please help, thanks! (1 Reply)
Discussion started by: kokoro
1 Replies

5. UNIX for Dummies Questions & Answers

rename a file if it exceeds 1MB in size

Hi all. I am trying to write a script that renames a logfile if it exceeds roughly 1 MB. My find command is: find some_logfile -type f -size +20000 Now I want to do my processing if it finds a file or not... How can I go about this? The $? is 0 if it finds a file or not. All... (4 Replies)
Discussion started by: jamie_collins
4 Replies

6. UNIX for Dummies Questions & Answers

Creating File using the CAT Command

Hello , I am newbie to UNIX platform . I have read that there are two ways of creating files that is using 1.) Cat 2.) touch . With Cat Command i am unable to create a File , i is saying No file or Directory exists I logged in with root as user . please help (7 Replies)
Discussion started by: Ravi Pavanv
7 Replies

7. Shell Programming and Scripting

Creating a command on a BASH shell

Hi all. Suppose I have the following function in an executable file named "HOLA": ------------------------ function hola { echo "Hola ${@}."; } ------------------------ In addition, suppose that I want to execute the file so I can input my name next to ./HOLA. I mean,... (4 Replies)
Discussion started by: hresquivelo
4 Replies

8. UNIX for Dummies Questions & Answers

Creating a file that contains output from a command, and then displays itself

hey, I'm trying to create the command that will create a file named user.txt that contains the output of the command cut -d: -f1,5 /etc/passwd, and displays itself afterwards. I don't know how to bridge cat > user.txt with cut -d: -f1,5 /etc/passwd, or how display it afterwards. Any help would... (2 Replies)
Discussion started by: raidkridley
2 Replies

9. Shell Programming and Scripting

Creating a command history feature in a simple UNIX shell using C

I'm trying to write a history feature to a very simple UNIX shell that will list the last 10 commands used when control-c is pressed. A user can then run a previous command by typing r x, where x is the first letter of the command. I'm having quite a bit of trouble figuring out what I need to do, I... (2 Replies)
Discussion started by: -=Cn=-
2 Replies

10. Shell Programming and Scripting

Help with a shell script for creating a log file

I have a schell script that runs continously on an AIX system. It is actually started from another shell script with the "ksh -x" command and then I just write the output to a log file. This causes the log files to be filled with mostly useless information. I would like to modify this script to... (2 Replies)
Discussion started by: heprox
2 Replies

Featured Tech Videos