From: Lynne Williams Date: Sun, 17 Feb 2013 17:26:36 +0000 (-0500) Subject: Update shell_cheatsheet.md X-Git-Url: http://git.tremily.us/?p=swc-modular-shell.git;a=commitdiff_plain;h=f02f4e924ffb0b1fa85f3662d91d83982a59241c Update shell_cheatsheet.md --- diff --git a/shell_cheatsheet.md b/shell_cheatsheet.md index aab5063..456c7d9 100644 --- a/shell_cheatsheet.md +++ b/shell_cheatsheet.md @@ -165,7 +165,8 @@ continues the loop as long as the value in the variable COUNTER is less than 10 ## 6. Finding Things ### a) How to select lines matching patterns in text files... -To find information within files, you use a command called `grep`. +To find information within files, you use a command called `grep`. + | Example command | Description | |--------------------------------|------------------------------------------------------------------------------------------------| | `grep [options] day haiku.txt` | finds every instance of the string `day` in the file haiku.txt and pipes it to standard output | | @@ -183,10 +184,17 @@ To find information within files, you use a command called `grep`. ### b) How to find files with certain properties... To find file and directory names, you use a command called `find` +| Example command | Description | +|------------------|-------------| +| `find . -type d` | `find` recursively descends the directory tree for each path listed to match the expression given in the command line with file or directory names in the search path | + + +#### b.1) Commonly used `find` options -* **`find . -type d` --> - * **`-type [df]`** --> d lists directories; f lists files - * **`-maxdepth n`** --> `find` automatically searches subdirectories. If you don't want that, specify the number of levels below the working directory you would like to search - * **`-mindepth n`** --> starts `find`'s search n levels below the working directory +| | `find` options | +|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| +| `-type [df]` | `d` lists directories; `f` lists files | +| `-maxdepth n` | `find` automatically searches subdirectories. If you don't want that, specify the number of levels below the working directory you would like to search | +| `-mindepth n` | starts `find`'s search `n` levels below the working directory |