Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 May 2003 02:03:30 +0200
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Jerry McAllister <jerrymc@clunix.cl.msu.edu>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Zeros and ones
Message-ID:  <20030503000330.GA98398@falcon.midgard.homeip.net>
In-Reply-To: <200305022353.h42NreOY018887@clunix.cl.msu.edu>
References:  <200305022353.h42NreOY018887@clunix.cl.msu.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, May 02, 2003 at 07:53:40PM -0400, Jerry McAllister wrote:
> Hi,
> 
> This should be easy, but short of writing something specific to do it,
> I am not getting my head around how.
> 
> It is easy and convenient to use /dev/zero to write out a number of
> zero bytes to somewhere - as in: 
> 
>           dd if=/dev/zero of=zerofile bs=512 count=1770000
>                 or
>           dd if=/dev/zero of=/dev/da1 bs=512 count=1770000
> 
> But, I would like to write all ones - as in 0xff or maybe some
> other pattern - as if there was a /dev/one also.
> 
> Is there a nice way to do this using UNIXistic stringing existing
> stuff together?   Or do I have to write a little piece of code?

Of course there is a nice way. :-)

Try something like

tr '\000' '\377' < /dev/zero | dd of=onesfile bs=512 count=1770000

to get a file with all bits equal to one.



-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030503000330.GA98398>