[TAG] 2-cent tip: Summing up file sizes
ben at linuxgazette.net
Mon Jul 16 00:27:46 MSD 2007
On Sun, Jul 15, 2007 at 08:42:29PM +0100, Martin J Hooper wrote:
> Ben Okopnik wrote:
> > ben at Tyr:/tmp$ for n in `seq 5`; do head -1000c /dev/full >
> > foo/$n; done
> Ben can you explain this line a bit more?
> Its obvious its
> looping 5 times to create the files but how is that head command
It grabs the "first" 1000 bytes ('c'haracters) from "/dev/full" and
redirects them into a file in "foo/"; the name of the file is, of
course, the same as the loop iterator - 1 through 5 depending on the
> and should that be /dev/null not /dev/full ? ;)
Nope. In electrical terms, "/dev/null" is a byte sink, whereas
"/dev/full" is a byte source (although that's not what it's designed
for; you generally want to use "/dev/zero" as an infinite source of null
bytes.) See also "/dev/urandom" if you need lots of line-noise.
All of this stuff is documented in "/usr/linux/Documentation/devices.txt" -
it's a good idea to be at least somewhat familiar with its contents.
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
More information about the TAG