> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/unix/grep-print-only-matched.md).

# grep print only matched

you can use the `-o` flag to only print matched value. Example

```
$ echo "Hello fellow unix fan" | grep --color -o nix
nix
$ echo "Hello fellow unix fan" | grep --color -o nux 
$ echo $?
1
```
