Question: I am trying to use grep with the `pwd` command.

So, if i enter `pwd`, it shows me something like:

```
/home/hrq/my-project/

```

But, for purposes of a script i am making, i need to use it with grep, so it only prints what is after `hrq/`, so i need to hide my home folder always (the `/home/hrq/`) excerpt, and show only what is onwards (like, in this case, only `my-project`).

Is it possible?

I tried something like

`pwd | grep -ov 'home'`, since i saw that the "-v" flag would be equivalent to the NOT operator, and combine it with the "-o" only matching flag. But it didn't work.

Answer: 
Given:

```
$ pwd
/home/foo/tmp

$ echo "$PWD"
/home/foo/tmp

```

Depending on what it is you really want to do, either of these is probably what you really should be using rather than trying to use grep:

```
$ basename "$PWD"
tmp

$ echo "${PWD#/home/foo/}"
tmp

```
Use `grep -Po 'hrq/\K.*'`, for example:

```
grep -Po 'hrq/\K.*' <<< '/home/hrq/my-project/'
my-project/

```

Here, `grep` uses the following options:  

`-P` : Use Perl regexes.  

`-o` : Print the matches only (1 match per line), not the entire lines.

`\K` : Cause the regex engine to "keep" everything it had matched prior to the `\K` and not include it in the match. Specifically, ignore the preceding part of the regex when printing the match.

**SEE ALSO:**  

[`grep` manual](https://www.gnu.org/software/grep/manual/grep.html)  

[perlre - Perl regular expressions](https://perldoc.perl.org/perlre)