This is an old revision of the document!


Linux File Operations

For example, find directories containing Python source files.

find /c/home/db/ -type f -name '*.py' | sed -r 's|/[^/]+$||' | sort | uniq
  • sed -r 's|/[^/]+$||' eats off the file name of a fully qualified file path, leaving only the path.
  • For each file path sed finds the filename and replaces it with a null string and the rest of the string/path is returned.

Find all the directories containing *.py files modified in the last 15 minutes.

find /c/home/db/ -mmin -15 -type f -name '*.py' | sed -r 's|/[^/]+$||' |sort|uniq
  • linux/file_operations.1512149672.txt.gz
  • Last modified: 2017/12/01 17:34
  • by mgupton