Solved Piping output to a file

I am doing some disk testing and would like to save output to a file. What do I use?
diskinfo -t /dev/ada0 | >output.file

I see print and gawk?
 
I don't understand the question. Is part of the command you posted missing? I don't see print or gawk.

A simple redirect diskinfo -t /dev/ada0 > output.file works fine.
 
Pipes are exclusively for connecting stdout from a process to stdin of the next process in a chain of arbitrary length. In sh(1) terminology, you are talking about "Redirections" (search for that section of the man page). If you also need to capture stderr, that is file descriptor #2 (stdin is 0, and stdout is 1), so you can use either of the following:
  • command >stdout-file 2>stderr-file
  • command >stdout-and-stderr-combined-file 2>&1
Redirections are handled by the shell, and are not part of the command line as seen by the command that is being run. Other shells may have some additional/alternate redirection syntax; the above only applies to sh-like shells. csh(1) has different syntax for all but the basic stdin and stdout cases.

Minor pedantry, I've never heard of '>' being described as "carrot". You may be thinking of "caret", which refers to '^'. '>' is simply "greater than", if the symbol needs to be described. Colloquially, to describe a Unix command line in spoken English, "output to", or "redirect to" might be used. There is, of course, the RFC 1345 digraph of "'>" to represent caret/circumflex (which comes from the character not being present on some keyboards), but that's just a character entry mechanism, not an actual character; and not applicable in this case.
 
Why does the root shell use tsch but under "Add Users" it defaults to csh for new users? Is this to differentiate the root console? I am unsure I have the right shells stated there either. I know root default shell is different than new users default shell.

Not a big deal and I know I can choose whatever shell I want. I just wonder why not consistent. Is this by design?
 
Why does the root shell use tsch but under "Add Users" it defaults to csh for new users? Is this to differentiate the root console? I am unsure I have the right shells stated there either. I know root default shell is different than new users default shell.

Not a big deal and I know I can choose whatever shell I want. I just wonder why not consistent. Is this by design?

The real answer may be lost in the mists of time. Digging back into history, 3BSD in early 1980 has /bin/sh for root, but 4BSD in late 1980 has /bin/csh; but I can't be certain that those sources might not have been modified post-release/distribution, and could reflect a personal choice of someone. FreeBSD's root (in recent releases, at least) defaults to /bin/csh, but toor uses /bin/sh (which is the system default shell).

The final 4.4BSD from CSRG, pre-Deathstar-settlement, has root on /bin/csh and toor on /bin/sh, in an /etc/passwd dated 1994.

In general, it shouldn't really matter which shell is configured for root, as all of the system scripts should run using an explicit choice of shell (typically through the shebang at the top of the script), and most things should not depend on the root user's environment. That said, I don't recommend changing it, and it certainly must not be changed to something which does not exist in the base system (i.e. root should never have a shell from ports, or a shell which links to dynamic libraries from ports); mostly so that the shell doesn't break (i.e. so you can still login as root when the all of the ports have gone wrong, or similar), but it's also a slightly increased security risk. If /usr is a separate filesystem, root should not even have a shell from /usr/bin; its shell should always come from the root filesystem (i.e. /bin or /sbin).

The unique situation with root means that it needs to work with not just what is on the system today, but also with whatever the OS vendor might push out tomorrow. While it should be unlikely to conflict, the safe course of action is not to change it, and there mostly isn't a good reason to change it. As a general principle, I never ever change root's shell from the system default, and I have never permitted anyone else to change it on systems where I have that level of authority; instead I just exec my-favourite-shell after login/su/sudo.
 
The command you are running doesn't require a pipe! But if you really, really, want to use it, try the following:
diskinfo -t /dev/ada0 | cat > benchmark.log
 
Back
Top