Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go

Find Files

20190331 The find command is a powerful tool used to discover files that match a pattern and then to perform some action with that file. The default is simply to print the full path and name of the files found. Here we find files somewhere in the current folder and down the hierarchy with a name that finishes with .jpg:

$ find . -name '*.jpg'

This will simply list the files so found. We can perform some other action on the files using -exec:

find . -name '*.jpg' -exec mv {} /media/sabrina/photos/ \;

The curly brackets are replaced by the file name and the escaped semicolon terminates the command string that belongs to the -exec.

Copyright © 1995-2019 Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
Brought to you by Togaware and the author of open source software including Rattle and wajig.
Also the author of Data Mining with Rattle and Essentials of Data Science.