Apache web server for windows - CHAPTER 17 COOL SHELL TRICKS Let s assume

CHAPTER 17 COOL SHELL TRICKS Let s assume that you have a directory that is packed full of files. You want to do a long directory listing (ls l) to see what permissions various files have. But doing this produces reams of output that fly off the screen. Typing something like the following provides a solution: ls l | less The | symbol between the two commands is the pipe. It can be found on most US keyboards next to the square bracket keys (above the Enter key; you ll need to hold down the Shift key to get it). What happens in the example is that ls l is run by the shell, but rather than sending the output to the screen, the pipe symbol (|) tells BASH to send it to the command that follows to less. In other words, the listing is displayed within less, where you can read it at your leisure. You can use Page Up and Page Down or the arrow keys to scroll through it. Once you quit less, the listing evaporates into thin air; the piped output is never actually stored as a file. In the previous section, you saw how you can use the history command to view the command history. At around 1,000 entries, its output scrolls off the screen in seconds. However, you can pipe it to less, like so: history | less Figure 17-3 shows the result on my test PC. Figure 17-3. Piping the output of the history command into the less command lets you read the output fully. You can pipe the output of any command. One of the most common uses is when searching for a particular string in the output of a command. For example, let s say you know that, within a crowded directory, there s a file with a picture of some flowers. You know that the word flower is in the filename, but can t recall any other details. One solution is to perform a directory listing,

Leave a Reply