_                    _       _        _     _                 _                              
  (_) __ _ _ __ ___  __| |   __| | ___  | |__ | | __ _ _ __   __| | ___ _ __ ___ ___  _ __ ___  
  | |/ _` | '__/ _ \/ _` |  / _` |/ _ \ | '_ \| |/ _` | '_ \ / _` |/ _ \ '__/ __/ _ \| '_ ` _ \ 
  | | (_| | | |  __/ (_| | | (_| |  __/ | |_) | | (_| | | | | (_| |  __/ | | (_| (_) | | | | | |
 _/ |\__,_|_|  \___|\__,_|  \__,_|\___| |_.__/|_|\__,_|_| |_|\__,_|\___|_|(_)___\___/|_| |_| |_|
|__/                                                                                            

5pm web | code | del.icio.us | gmail | hulu | quick diff | pics | contact me
Google



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

Linux Screen Hot Keys

Key Combo Function
Ctrl+a " List active screens.
Ctrl+a c Create new screen.
Ctrl+a n View Next screen.
Ctrl+a p View Previous screen.
Ctrl+a Shift+D Try to detatch a frozen screen. This will not always exit cleanly.
Ctrl+a Ctrl+/ Same as above. Try to detatch a frozen screen. This will not always exit cleanly.
More Screen Commands