^ in regex matches the beginning of the string this prevents it from matching the pattern if it doesn't occur in the beginning of the file name. Regex is an extremely powerful searching tool if you master it, and there are sites such as this which teach you about it in more depth, but note that grep is not a full-fledged regex engine and you can't do everything with it. Now the pattern itself is written in a particular syntax called regular expression, or regex for short. Notice that the pattern is quoted with single quotes ' ' to prevent the shell from interpreting the special characters inside it.Grep takes the output and filters it using the given pattern, ^\./ABC. The pipe character | redirects the output of one command to another, in this case the output of find is redirected to grep. Being aware of this is important because it means we will search for results starting with. , indicating that their path is relative to the current directory.
Note that find outputs each file or directory starting with. To understand the command, let's break it down a bit:įind lists all files under the current directory and its sub-directories using it alone will just list everything there. Generally, if you want to just list them, you can do it in a terminal using:
There are many ways to do it, depending on exactly what you want to do with them.