< Day Day Up > |
4.4. grep with PipesInstead of taking its input from a file, grep often gets its input from a pipe. Example 4.29.% ls -l drwxrwxrwx 2 ellie 2441 Jan 6 12:34 dir1 -rw-r--r-- 1 ellie 1538 Jan 2 15:50 file1 -rw-r--r-- 1 ellie 1539 Jan 3 13:36 file2 drwxrwxrwx 2 ellie 2341 Jan 6 12:34 grades % ls -l grep '^d' drwxrwxrwx 2 ellie 2441 Jan 6 12:34 dir1 drwxrwxrwx 2 ellie 2341 Jan 6 12:34 grades EXPLANATION The output of the ls command is piped to grep . All lines of output that begin with a d are printed; that is, all directories are printed. 4.4.1 grep ReviewTable 4.3 contains examples of grep commands and what they do. Table 4.3. Review of grep
|
< Day Day Up > |