28.09.2018 Views

Linux Dummies 9th

Create successful ePaper yourself

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

328<br />

Part IV: Junior Administrator Boot Camp<br />

The cat command (and more) is explained in Appendix A.<br />

Note that if you type ls -l > listing again, the data is overwritten,<br />

meaning that the file’s contents are wiped out and replaced with the new<br />

output. You can avoid this situation by using >> as your redirection operator,<br />

which tells bash to add the command’s output to the end of the specified<br />

file. If you type ls -l >> listing in the same directory after making no<br />

changes, the contents of listing are as follows:<br />

rich@testbox:~$ ls -l<br />

total 36<br />

drwxr-xr-x 2 rich rich 4096 2009-05-20 18:56 Desktop<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Documents<br />

drwxr-xr-x 4 rich rich 4096 2009-05-17 17:42 GNUstep<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Music<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Pictures<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Public<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Templates<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Videos<br />

rich@testbox:~$<br />

rich@testbox:~$ ls -l<br />

total 36<br />

drwxr-xr-x 2 rich rich 4096 2009-05-20 18:56 Desktop<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Documents<br />

drwxr-xr-x 4 rich rich 4096 2009-05-17 17:42 GNUstep<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Music<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Pictures<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Public<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Templates<br />

drwxr-xr-x 2 rich rich 4096 2009-05-17 14:09 Videos<br />

rich@testbox:~$<br />

Laying pipes<br />

Another bash shell feature enables you to connect commands so that the<br />

output of one becomes the input for the next one. This feature is referred to<br />

as a pipe. Suppose you want to look over the details of all the files in the /<br />

etc directory in long-listing format. If you type ls -la /etc to do so, a<br />

massive listing appears, and much of the information scrolls right past you.<br />

Although you can back up a bit by pressing Shift+PageUp, you may not be<br />

able to see everything you want to see.<br />

To see all the information, you can do one of two things:<br />

✓ Send the data to a file with redirection by typing something like<br />

ls -l /etc > ~/etclisting — and then review the contents of<br />

~/etclisting with your favorite editor.

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

Saved successfully!

Ooh no, something went wrong!