Element 14 Raspberry Pi User Manual page 15

Table of Contents

Advertisement

Pipes and redirection
The commands that we've been looking at so far have all
sent their output to be displayed in the terminal.
Most of the time this is what we want, but
sometimes it's useful to do other things with
it. In Linux, you can do two other things with
a command: send it to a file, or send it to
another program. To send it to a file, use the
>
character followed by the filename. Run:
ls > files
cat files
and you should see that it creates
a new file called
files
, which
contains the output of
ls
The second option, sending it to another
program, is another of the really powerful
features of the Linux command line,
because it allows you to chain a series of
commands together to make one super
Use the sudo command to switch between the normal user 'pi', and the superuser 'root'.
Raspberry Pi User Guide.indd 15
command. There are a lot of commands
that work with text that are designed to
be used in this way. They're beyond the
scope of this tutorial, but as you continue to
use the command line, you'll come across
them and start to see how they can be
linked together. We'll take a look at a simple
example. If you run
yet!) it will list every file on the system.
This will produce a reel of filenames that
will quickly go off the screen. However,
.
rather than direct it to the screen, we can
send (or 'pipe') it to another command
that makes the output easier to read.
We can use the
looked at on page 13 for this. Run:
find / | less
find /
(don't do it just
less
command that we
Take it further
We've only been able to touch
on the basics of using the
command line, but you should
have enough knowledge
now to get started, and
hopefully you're beginning
to see just how powerful the
command line interface is
once you get to know it.
If you want to know more (and
you should!) there are loads of
resources in print and online.
LinuxCommand.org
place to start. Its book ( The
Linux Command Line ) is available
from bookshops, or for free
online
www.linuxcommand.org/
lc3_learning_the_shell.php.
is a great
15
08/07/2014 14:44

Hide quick links:

Advertisement

Table of Contents
loading

Related Products for Element 14 Raspberry Pi

Table of Contents