How to create a file of the specified size in Linux and WinDOS

Source: Internet
Author: User

A method that creates a specified file size on a Lnix uses the DD command

Function: Copies the specified input file into the specified output file, and can be converted in format during the copy process. You can use this command to implement the diskcopy command under DOS. First use the DD command to write the data on the floppy disk to a storage file, and then the storage file written to the second floppy disk, complete the function of diskcopy. It should be noted that the storage file on the hard disk should be removed with the RM command. The system uses standard input files and standard output files by default.

Syntax: DD [Options]

if = input file (or device name).

of = output file (or device name).

IBS = Bytes Reads bytes bytes At a time, that is, the number of bytes read into the buffer.

Skip = Blocks skips the ibs*blocks block that reads into the beginning of the buffer.

Obs = bytes Writes bytes bytes At a time, that is, the number of bytes written to the buffer.

BS = bytes Sets the number of bytes in the read/write buffer (equal to the set IBS and OBS).

CBS = Byte converts bytes bytes at a time.

The count=blocks only copies the input blocks blocks.

CONV = ASCII Converts the EBCDIC code to Ascil code.

Conv = EBCDIC converts ascil code to EBCDIC code.

CONV = IBM converts ascil code to alternate EBCDIC code.

CONV = Block Converts the change bit to a fixed character.

CONV = Ublock Converts the fixed bit into a change bit.

CONV = UCase Converts the letter from lowercase to uppercase.

CONV = LCase converts letters from uppercase to lowercase.

CONV = Notrunc does not truncate the output file.

CONV = swab swaps each pair of input bytes.

CONV = NoError does not stop processing when an error occurs.

Conv = sync puts the size of each input record to the size of the IBS (filled with nul).

 

Example 1: To copy the contents of one floppy disk to another floppy disk, use/TMP as the temporary storage area. Insert the source disk into the drive and enter the following command:

$ dd if =/dev/fd0 of =/tmp/tmpfile

After the copy is complete, remove the source disk from the drive, insert the target disk, and enter the command:

$ dd if =/tmp/tmpfile of =/dev/fd0

After the floppy copy is complete, the temporary files should be deleted:

$ rm/tmp/tmpfile

 

Example 2: Write the net.i file to a floppy disk and set the number of read/write buffers.

(Note: The contents of the floppy disk will be completely overwritten)

$ dd if = net.i of =/dev/fd0 bs = 16384

 

Example 3: Copy the file sfile to the file Dfile.

$ dd If=sfile Of=dfile

Example 4: Creating an empty 100M file

DD If=/dev/zero of=hello.txt bs=100m count=1

=============================================

/dev/null, nicknamed the Bottomless pit, you can output any data to it, it take all, and will not hold!
/dev/zero, is an input device that you can use to initialize files.


/dev/null------It is an empty device, also known as a bit bucket (bits bucket). Any output written to it will be discarded. If you do not want the message to display or write to the file in standard output, you can redirect the message to the bin.
/dev/zero------The device provides an exhaustive 0, you can use any number you need-the device provides much more. He can be used to write a string 0 to a device or file.
$ dd If=/dev/zero of=./test.txt bs=1k count=1
$ ls-l
Total 4
-rw-r--r--1 Oracle DBA 16:56 test.txt

eg

$ find/-name Access_log 2>/dev/null

On Lnix systems, you can use the DD command to quickly create files.
So above windows, is there a similar tool for creating files? The answer is YES!
Use the fsutil command. The command format is:
fsutil file createnew <filename> <length>
Fq:fsutil file createnew c:\abc.txt 10240000

How to create a file of the specified size in Linux and WinDOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.