Linux Command Line Tips
Find Files Containing Text
Find a file of a certain extension containing a certain text phrase in the current directory and its subdirectories. In the example below we are searching for select data_element in .php files.
find | grep .php | xargs grep -s "select data_element"
It can be quite useful to append a clear; to the start of this command to give a clean output each time it is run.
clear; find | grep .php | xargs grep -s "select data_element"
Need to review a long listing? Pipe the results to less. Press q to exit less.
clear; find | grep .php | xargs grep -s "select data_element" | less
Find Recently Modified Files
Want to see all the .php files modified in the last 5 days?
clear; find -mtime -5 -print | grep .php
Need to review a long listing? Pipe the results to less. Press q to exit less.
clear; find -mtime -5 -print | grep .php | less
|