redirect output to file

I need to redirect output of

dd if=/dev/zero of=/dev/null bs=512 count=4096

to file

I tried
dd if=/dev/zero of=/dev/null bs=512 count=4096 > file
printing empty file

dd if=/dev/zero of=/dev/null bs=512 count=4096 > file 2>&1
getting ambigious output
 
The way redirection works depends on the shell you're using. Judging by the error on the second command, where you used the bourne shell syntax, you're on the csh(1). The dd(1) command prints to stderr, not stdout. That's why the first redirection didn't output anything to the file.

dd if=/dev/zero of=/dev/null bs=512 count=4096 >& file

Code:
       > name
       >! name
       >& name
       >&! name
               The file name is used as standard output.  If the file does not
               exist then it is created; if the file exists, it is truncated,
               its previous contents being lost.

               If the shell variable noclobber is set, then the file must not
               exist or be a character special file (e.g., a terminal or
               `/dev/null') or an error results.  This helps prevent
               accidental destruction of files.  In this case the `!' forms
               can be used to suppress this check.  If notempty is given in
               noclobber, `>' is allowed on empty files; if ask is set, an
               interacive confirmation is presented, rather than an error.

               The forms involving `&' route the diagnostic output into the
               specified file as well as the standard output.  name is
               expanded in the same way as `<' input filenames are.
 
Which output, and what do you mean by "ambiguous"?

If the intent was just to fill a file with zero-bytes, there's no need to redirect anything, just use of=yourfile.
 
and what do you mean by "ambiguous"?
If you use the bourne shell style output redirection 2>&1 > file on csh(1) you get an Ambiguous output redirect message.
Code:
dice@williscorto:~ % echo $SHELL
/bin/tcsh
dice@williscorto:~ % echo some test 2>&1 > test
Ambiguous output redirect.

The reason is that this gets interpreted as > file1 > file2, so you get two redirections of stdout to different files. Hence the ambiguity.
 
ive ran below command on HDD(local machine),SSD and NVM disks(digital ocean server). but getting same result which is rotation rate is unknown. any reason?

Code:
root@mfsbsd:~ # diskinfo -v ada0
ada0
    512             # sectorsize
    17179869184     # mediasize in bytes (16G)
    33554432        # mediasize in sectors
    0               # stripesize
    0               # stripeoffset
    33288           # Cylinders according to firmware.
    16              # Heads according to firmware.
    63              # Sectors according to firmware.
    VBOX HARDDISK    # Disk descr.
    VB9cefb55e-f72b70cf    # Disk ident.
    No              # TRIM/UNMAP support
    Unknown         # Rotation rate in RPM
    Not_Zoned       # Zone Mode
 
On a local disk on a real physical machine, "diskinfo -v" gives me reasonable answers. I would not use it though, since it is just a wrapper around the real information that comes from the disk. Instead, I would use "camcontrol identify" or "camcontrol inquiry", which gives you the SCSI/SATA standard answer.

On a virtual disk (for example a cloud or hosting provider), the rotation rate question probably makes no sense. The disk you see is constructed from a variety of hardwares, and probably involves a disk server (a dedicated computer), using multiple layers of storage device (reflective memory, SSD, perhaps even fast NVRAM such as 3DXpoint, fast disk, slow disk).

If you want to know the performance of your disk, you can use various disk benchmarks. SirDice already pointed you at Bonnie, which gives a very crude overall rating. FIO is a bit more detailed and scientific. No canned benchmark, however, will ever reflect your actual workload. People who are serious about this have their own benchmark suites (and some of those leak out on the internet). But the best benchmark is actually running your application in a controlled way.
 
Back
Top