Tutorials

Find all files containing a given string

A quick one-liner to recursively search files for a given text string.

Open up a terminal session and enter the following - replacing "foo" with the text to search for.

python
find . -exec grep -l "foo" {} \;

You can also limit the search to files with a particular extension (e.g. HTML or CSS). The first form will only return files in the current directory

python
find *.html -exec grep -l "foo" {} \;

Alternatively you can search recursively while matching filenames using the -name parameter:

python
find . -name *.html -exec grep -l "foo" {} \;

You can pass other options to find including for example -mtime -1 to specify only files modified within the past day. You can also replace . with the name of any other folder to search:

python
find /var/www -name *.html -exec grep -l "foo" {} \;

This will search /var/www recursively for files named *.html and containing foo.

PyQt/PySide 1:1 Coaching with Martin Fitzpatrick

Save yourself time and frustration. Get one on one help with your Python GUI projects. Working together with you I'll identify issues and suggest fixes, from bugs and usability to architecture and maintainability.

Book Now 60 mins ($195)

Elsewhere

Collaborate in the shell with screen (multiuser)
Bash Command Substitution
Use bash brace expansion to save {hours,days}
Build a Translation Application Using Tkinter and OpenAI