Question: How to give a pattern for new line in grep?
New line at beginning, new line at end. Not the regular expression way. Something like \n.

Answer: 
try `pcregrep` instead of regular `grep`:

```
pcregrep -M "pattern1.*\n.*pattern2" filename

```

the `-M` option allows it to match across multiple lines, so you can search for newlines as `\n`.
Thanks to @jarno I know about the -z option and I found out that when using GNU grep with the -P option, *matching against `\n` is possible*. :)

**Example:**

```
grep -zoP 'foo\n\K.*'<<<$'foo\nbar'

```

Result:

```
bar

```

**Example that involves matching everything including newlines:**

`.*` will not match newlines. To match everything including newlines, use1 `(.|\n)*`:

```
grep -zoP 'foo\n\K(.|\n)*'<<<$'foo\nbar\nqux'

```

Result:

```
bar
qux

```

1 Seen here: <https://stackoverflow.com/a/33418344>