13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

8Chapter 1An Embarrassment of Riches: The <strong>Linux</strong> Envir<strong>on</strong>mentNote there is no output visible from ls. The error message, ls: bogus:No such file or directory, has been written to the file save.out.In a similar way standard input (stdin) can be redirected from its defaultsource, the keyboard.As an example, we’ll run the sort program. Unless you tell it otherwise,sort will read from stdin—that is, the keyboard. We type a short list ofphrases and then type a ^D (a C<strong>on</strong>trol-D) which w<strong>on</strong>’t really echo to the screenas we have shown but will tell <strong>Linux</strong> that it has reached the end of the input.The lines of text are then printed back out, now sorted by the first character ofeach line. (This is just the tip of the iceberg of what sort can do.)$ sort<strong>on</strong>ce up<strong>on</strong> a timea small creaturecame to live inthe forest.^Da small creaturecame to live in<strong>on</strong>ce up<strong>on</strong> a timethe forest.Now let’s assume that we already have our text inside a file calledstory.txt. We can use that file as input to the sort program by redirectingthe input with the “ wc.fields$ java MyCommand < data.file | grep -i total > out.put

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!