> ## Content Index
> Fetch the complete content index at: https://kudithipudi.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# HOW TO : grep options to display before and after lines of matching content
- URL: https://kudithipudi.org/how-to-grep-options-to-display-before-and-after-lines-of-matching-content/
- Published: 2012-04-29T13:59:51.000Z
- Updated: 2012-04-29T13:59:51.000Z
- Description: For my own notes.. if you are using grep to parse through the contents of a file and want to see the preceding or proceeding content...
- Author: admin
- Tags: HOWTO, Linux, Technology, Uncategorized, #wp, #wp-post, #Import 2026-08-23 02:32

For my own notes.. if you are using grep to parse through the contents of a file and want to see the preceding or proceeding content than the line that matched your query, you can use the following options

**preceding content**

```
grep -B NUMBER_OF_LINES_TO_DISPLAY query filename
```

for example, if I was searching for kudithipudi in a file names access.log and want to see 2 lines prior to the match, I would use

```
grep -B 2 kudithipudi access.log
```

**proceeding content**

```
grep -A NUMBER_OF_LINES_TO_DISPLAY query filename
```

for example, if I was searching for kudithipudi in a file names access.log and want to see 2 lines after the match, I would use

```
grep -A 2 kudithipudi access.log
```

**preceding and proceeding content**

```
grep -C NUMBER_OF_LINES_TO_DISPLAY query filename
```

for example, if I was searching for kudithipudi in a file names access.log and want to see 2 lines before and after the match, I would use

```
grep -C 2 kudithipudi access.log
```