You are looking at the HTML representation of the XML format.
HTML is good for debugging, but probably is not suitable for your application.
See complete documentation, or API help for more information.
<?xml version="1.0"?>
<api>
  <query-continue>
    <allpages gapfrom="Regular expressions" />
  </query-continue>
  <query>
    <pages>
      <page pageid="1086" ns="0" title="Recommended applications">
        <revisions>
          <rev xml:space="preserve">==Setting up a workstation==
See our [[Complete_Workstation]] write-up on how to get a desktop system up and running.

==Installation==

You can get these by [[Installing ports]] or by [[Installing packages]]

==Web Browsing==

[[Firefox]], [[Mozilla]], links, [[lynx]], [[dillo]], Opera.

Since 05 Nov 2005 06:04:48 the Development Branch of Firefox is also included in the Ports Tree under &lt;i&gt;/usr/ports/www/firefox-devel&lt;/i&gt;.

==Email==

Thunderbird, Mozilla Mail, mutt, sylpheed, pine

==Multimedia==
Note that to get sound working under FreeBSD, you'll need to enable your [[sound card]]

beep-media-player, [[xmms]], [[Mplayer]], [[helix]], [[realplayer]], [[VLC]], [[amarok]]

==CD burning and ripping==

[[X-CDRoast]], cdrtools [burncd], [[k3b]], [[grip]]

If you get any errors along the lines of &quot;can't access /dev/acd0&quot; from one of your CD reading/writing applications, your problem is probably the permissions on /dev/acd0 (or whatever your device is). A quick
 chmod 644 /dev/acd0
will probably fix it.

==Productivity==

[[OpenOffice.org]] (requires [[Java]]), AbiWord (no Java required), xpdf, evince (also does pdf)



[[Category:FreeBSD for Workstations]]</rev>
        </revisions>
      </page>
      <page pageid="865" ns="0" title="Redirection">
        <revisions>
          <rev xml:space="preserve">'''Redirection''' is sending the output of a program to somewhere other than where it would otherwise go - for example you can '''redirect''' the output of an [[ls]] command to a text file for later processing or to the [[grep]] command for filtering.  Shell redirection operators include: '''&gt;''', '''&gt;&gt;''', '''&lt;''', '''&lt;&lt;''', and the ever popular '''|'''.

 &gt;  sends output to a file (may include [[special files]] such as [[/dev/null]])
 &gt;&gt; appends output to a file (without overwriting it)
 &lt;  read file to &lt;code&gt;stdin&lt;/code&gt;
 &lt;&lt; read to stdin from &lt;code&gt;&lt;&lt;delimiter&lt;/code&gt; to &lt;code&gt;delimiter&lt;/code&gt; (a ''HERE doc'').
  |  sends output to a program (frequently, a [[:Category:System Commands|system command]] like [[grep]])

If you're using the [[bash]] or [[bourne shell|bourne]] shells, you also have some special options available to you: you can redirect standard input, standard output and standard error messages with far greater flexibility and reliability.  Other shells such as [[csh]] are notably limited in redirection capability, making them better suited to interactive use than to [[shell programming]] or other complex uses.

== Shell pipelines and redirection ==
There are three standard input/output file descriptors (''fd'') that are preconnected to the shell process running on your FreeBSD machine.  Most commands that you would run from the command line expect these file descriptors to be open and accessible. The first (''fd 0'') provides a stream of ''input'' to your program, the second (''fd 1'') provides a stream of ''output'', and the third (''fd 2'') provides a stream of diagnostic messages (usually to your terminal).  

When you open a terminal, before running the shell the terminal device is opened three times to preconnect these file descriptors.  The shell then inherits the file descriptors, and passes them on to each process run from the shell.  

On FreeBSD systems it looks like this:
{| border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;
|-
! file descriptor || Stream  || file descriptor file || device path
|-
| '''0''' || Standard input  || &lt;code&gt;/dev/stdin&lt;/code&gt;   || /dev/fd/0
|-
| '''1''' || Standard output || &lt;code&gt;/dev/stdout&lt;/code&gt;  || /dev/fd/1
|-
| '''2''' || Standard error  || &lt;code&gt;/dev/stderr&lt;/code&gt;  || /dev/fd/2
|}

The example below demonstrates that by default, all of these input/output streams are directed to your terminal (color is added).  
 $ for i in stdin stdout stderr; do echo $i stuff &gt; /dev/$i; done
 &lt;span style=color:red  &gt; stdin stuff&lt;/span&gt;
 &lt;span style=color:green&gt;stdout stuff&lt;/span&gt;
 &lt;span style=color:blue &gt;stderr stuff&lt;/span&gt;

Redirection means that, the file descriptor is temporarily reassigned to somewhere other than the terminal device (a file, a pipe, another file descriptor).  When the next process inherits the open ''fd'' from the shell the stream of data is passed along, for example, by writing to &lt;code&gt;stdout&lt;/code&gt;, which has been temporarily reassigned to the &lt;code&gt;stdin&lt;/code&gt; for the next process by means of a ''pipe'' ('''|''').  This handing off of open file descriptors by the shell, from one sub-process to another, is called a &quot;shell pipeline&quot;.  

There are ''fd n'' (0-9) descriptors potentially available, but only 0-2 are preconnected to the shell; the others must be created from the shell.  In some shells, a standard file descriptor can be detached and reassigned to another file descriptor for as long as the terminal device is open,  using the [[exec]] command (examples appear below).  This capability is just one case among many of why &lt;code&gt;sh&lt;/code&gt; is useful for scripting, and &lt;code&gt;tcsh&lt;/code&gt; (which lacks it) is not (''see the [http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ FAQ]).

== Redirection in &lt;code&gt;sh&lt;/code&gt; compared to &lt;code&gt;tcsh&lt;/code&gt; ==
The c-shells (&lt;code&gt;tcsh&lt;/code&gt; or &lt;code&gt;csh&lt;/code&gt;) and the Bourne shells (&lt;code&gt;sh&lt;/code&gt; or &lt;code&gt;bash&lt;/code&gt;) do not handle redirection or piping in quite the same way.  

=== ''tcsh'' and ''sh'' ===
# Write output to a file
#: % mycmd &gt; out.txt
#:: &lt;span style=color:blue &gt;stderr stuff&lt;/span&gt;
# Append output to a file
#: % mycmd &gt;&gt; out.txt
#:: &lt;span style=color:blue &gt;stderr stuff&lt;/span&gt;
# Redirect the output of a remote command to ''local.txt''.
#: % localcmd &quot;remotecmd&quot; &gt; local.txt
#:: &lt;span style=color:blue &gt;stderr stuff&lt;/span&gt;
# Same command as above, showing only the changes compared to ''local.txt''.&lt;br /&gt;''Note: Many programs recognize '-' as a shortcut for '/dev/stdin'. These two commands are equivalent. ''
#: % localcmd &quot;remotecmd&quot; | diff /dev/stdin local.txt
#: % localcmd &quot;remotecmd&quot; | diff - local.txt
#:: &lt;span style=color:blue &gt;stderr stuff&lt;/span&gt;
# Direct &lt;code&gt;stdout&lt;/code&gt;+&lt;code&gt;stderr&lt;/code&gt; to file
#: % mycmd &gt;&amp; out.txt
# Sort lines of jumble.txt into sorted.txt&lt;br /&gt;''Note: the sequence in which redirection appears is not important.  All of the following are exactly equivalent.''
#: % &lt;jumble.txt sort &gt;sorted.txt
#: % &gt;sorted.txt sort &lt;jumble.txt 
#: % sort &lt; jumble.txt &gt;sorted.txt
#: % &lt;jumble.txt&gt;sorted.txt sort
#:: &lt;span style=color:blue&gt;stderr stuff&lt;/span&gt;
# Sort unique lines of jumble.txt into sorted.txt
#: % &lt;jumble.txt sort | uniq &gt;sorted.txt
#:: &lt;span style=color:blue&gt;stderr stuff&lt;/span&gt;
# Sort ''HERE doc'' delimited by &quot;lines&quot; 
#: % &lt;&lt;lines sort&lt;br /&gt;
#::? a second line&lt;br /&gt;
#::? a first line&lt;br /&gt;
#::lines&lt;br /&gt;&lt;span style=color:green &gt;a first line&lt;/span&gt;&lt;br /&gt;&lt;span style=color:green &gt;a second line&lt;/span&gt;&lt;br /&gt;&lt;span style=color:blue&gt;stderr stuff&lt;/span&gt;

=== ''tcsh'' only ===
# Discard errors, watch output (probably evil)&lt;br /&gt;''Note: There is no reliable way to do this in tcsh. Here we exploit the fact that terminal reads from &lt;code&gt;stdin&lt;/code&gt;.  ''
#: % ( mycmd &gt; /dev/stdin ) &gt; &amp; /dev/null
#:: &lt;span style=color:green  &gt; stdout stuff&lt;/span&gt;
#: % ( mycmd &gt; /dev/tty ) &gt; &amp; /dev/null
#:: &lt;span style=color:green &gt; stdout stuff&lt;/span&gt;
# Append output to out.txt; discard messages
#: % (mycmd &gt;&gt; out.txt) &gt;&amp; /dev/null
# Write output to out.txt; store and watch errors&lt;br /&gt;''Note: Compare the same task in ''sh''. ''
#: % ( mycmd &gt; out.txt ) | &amp; tee err.txt
#:: &lt;span style=color:blue &gt;stderr stuff&lt;/span&gt;
 
=== ''sh'' only ===
# Discard errors, watch output 
#: $  mycmd 2&gt; /dev/null
#:: &lt;span style=color:green  &gt; stdout stuff&lt;/span&gt;
# Append output to out.txt; discard messages
#: $ mycmd 2&gt; /dev/null &gt;&gt; out.txt
# Write output to out.txt; store and watch errors&lt;br /&gt;''Note: Compare the same task in ''tcsh''. ''
#: $ mycmd 2&gt;&amp;1 &gt; out.txt | tee err.txt
#:: &lt;span style=color:blue &gt;stderr stuff&lt;/span&gt;
# Write messages to err.txt; write output to out.txt and copy output to terminal
#: $ mycmd 2&gt; err.txt | tee out.txt
#:: &lt;span style=color:green&gt;stdout stuff&lt;/span&gt;
# Assign a variable from stored.txt
#: $ &lt;stored.txt read var; mycmd $var 
#:: &lt;span style=color:blue&gt;stderr stuff&lt;/span&gt;
#:: &lt;span style=color:green&gt;stdout stuff&lt;/span&gt;
# Assign first three lines of stored.txt to three different variables
#: $ exec 3&lt;&amp;0; exec &lt;stored.txt; read v1; read v2; read v3; exec 0&lt;&amp;3 3&lt;&amp;-; echo $v1 $v2 $v3
#:: &lt;span style=color:blue&gt;stderr stuff&lt;/span&gt;
#:: &lt;span style=color:green&gt;stdout stuff&lt;/span&gt;
# Use all unique lines in stored.txt as an argument variable for ''mycmd'', appending to result.txt
#: $ exec 3&lt;&amp;0; exec &lt;stored.txt; sort | uniq | while read line; do mycmd $line &gt;&gt; result.txt ; done; exec 0&lt;&amp;3 3&lt;&amp;-;
#:: &lt;span style=color:blue&gt;stderr stuff&lt;/span&gt;
: ''Note:'' By default, redirection pointed right represents &lt;code&gt;stdout&lt;/code&gt;, so that these two commands are exactly equivalent:
:: $ mycmd 1&gt; out.txt
:: $ mycmd &gt; out.txt
::: &lt;span style=color:blue &gt;stderr stuff&lt;/span&gt;
: ''Note:'' By default, redirection pointed left represents &lt;code&gt;stdin&lt;/code&gt;, so that these two commands are exactly equivalent:
:: $ mycmd 0&lt; in.txt
:: $ mycmd &lt; in.txt
::: &lt;span style=color:blue &gt;stderr stuff&lt;/span&gt;
::: &lt;span style=color:green &gt;stdout stuff&lt;/span&gt;
: ''Note:'' To close a file descriptor, say &lt;code&gt;n&lt;&amp;-&lt;/code&gt;
:: $ mycmd &gt;out.txt 1&lt;&amp;-;
:: ''-sh: fails without messages''
:: &lt;span style=color:blue &gt;-bash: mycmd: write error: Bad file descriptor&lt;/span&gt;

=== A little more about ''fd n'' in &lt;code&gt;sh&lt;/code&gt; ===

Let's say you want to send output to your screen and errors to another command. You '''can't''' just do
 samizdata# myprogram 1&gt;&amp;2 2&gt;&amp;1 | command &gt; errors.txt
because when you switched output to the messages file descriptor, it's done ''right away''.  When you tried to switch errors to output there's nothing left to pipe. It's exactly as though you had said 
 samizdata# myprogram 1&gt;/dev/stderr | command &gt; errors.txt
''command'' receives no data, because it's all been sent to your screen.  ''errors.txt'' will be empty.  If you had tried it the other way, it's just as though you would have said:
 samizdata# myprogram 2&gt;/dev/stdout | command &gt; errors.txt
In which case, errors and output are both piped to ''command'', which was not what you wanted.
 
This is where the other, normally unused, file descriptors 3-9 come in. You can use them as place-holders, like this:
 samizdata# myprogram 3&gt;&amp;2 2&gt;&amp;1 1&gt;&amp;3 | command &gt; errors.txt

Let's step through what this does.
# ''fd 3'' points to &lt;code&gt;stderr&lt;/code&gt;
# ''fd 2'' points to &lt;code&gt;stdout&lt;/code&gt;
# ''fd 1'' points to ''fd 3'' (which is connected to &lt;code&gt;stderr&lt;/code&gt;)
# ''|'' passes the open file descriptor connected to &lt;code&gt;stdout&lt;/code&gt; (''fd 2'') making it &lt;code&gt;stdin&lt;/code&gt; for ''command''
# ''&gt;'' redirects the output of ''command'' to ''errors.txt''.

So, what you'll see on your screen is the output of ''myprogram'' on &lt;code&gt;stderr&lt;/code&gt; (not passed to ''command''), followed by errors (if any) from ''command''.  In short, what's been accomplished is, a swap of errors for output, from ''myprogram'' to ''command'', the output of which is redirected to ''errors.txt''.  There is no reliable way to do the same thing in &lt;code&gt;tcsh&lt;/code&gt;.

Also, see the [http://www.freebsd.org/cgi/man.cgi?query=mkfifo&amp;apropos=0&amp;sektion=1&amp;manpath=FreeBSD+6.1-RELEASE&amp;format=html man page] for [[mkfifo]], a utility for creating arbitrary [[FIFO]] files.
[[Category:FreeBSD Terminology]] [[Category:Common Tasks]]</rev>
        </revisions>
      </page>
    </pages>
  </query>
</api>