Day 7: The find Command is too Powerful

I decided to use the Virtual Machine running Ubuntu to be more practical but when I was running the terminal I found the find program to be acting a bit different. So here we are reviewing the find program again to figure out what I’m doing wrong. The Manual is TOOO Long lol.

TLDR;

Okay, so here are the highlights of what I did:

  • Looked into the test options for the find program in the Bash shell.
  • Played around in the Ubuntu Virtual Machine to reacquaint myself with the environment.

The find Program

I might have mentioned previously that the find program has a crazy amount of options available to the user when it is run. Well today I tried to get more familiar with the test options. Here is what I found so far.

The part of the command line after the list of starting points is the expression. This is a kind of query specification describing how we match files and what we do with the files that were matched. An expression is composed of a sequence of things:

  • Tests
  • Actions
  • Global Options
  • Positional Options
  • Operators

Tests

Similar to the test program found in the shell we can run a test that will filter out what result we get from the execution of the find program.

-name pattern

$ find . -name PATTERN

Base of file name (the path with the leading directories removed) matches shell pattern pattern. Because the leading directories are removed, the file names considered for a match with -name will never include a slash, so `-name a/b’ will never match anything (you probably need to use -path instead).

Conclusion

I am pretty tired so that’s all for today. Btw if you are interested in the MIT course you can check out the video lecture I’m currently doing the exercises for. The lecture is helpful but isn’t sufficient by itself. Anyways, until next time PEACE!

YouTube player