Become a fan of Slashdot on Facebook


Forgot your password?
Check out the new SourceForge HTML5 internet speed test! No Flash necessary and runs on all devices. ×
Data Storage

Journal thePsychologist's Journal: Simple Find Files Script

Tired of searching your hard drive with GUI programs with too many features? Here's a handy script that will get the job done on any decent Linux setup. First type this in a terminal:

find -xdev / >> ~/dbase.txt

If you want other filesystems searched too remove -xdev. Anyways, this will output an entire list of files into a file called dbase.txt in your home directory. Put it wherever you want though if you care.

If you want even more useless junk searched put a sudo in front of that command to get some protected files (not useful).

Now that you have a static database of almost all the files on your computer, write up a script like this:

if test $# -eq 1
      grep -E -i $1 ~/dbase.txt
      if test $2 = -h
            grep -E -i $1 ~/dbase.txt | grep "/home/`whoami`"
            echo "invalid option"

Make it executable and put it in a scripts directory. Typing "isolate junk" will isolate all filenames containing "junk" (case insensitive). "isolate junk -h" will just use the home directory. Use any regular expression.

I found this kind of script very useful because I know where any of the files I use that change often are, and when I need to search I only need to find files which stay in the same place forever. The advantage is that it takes less than a second for queries and there's no space taken from a program, and of course it can be used in text-only mode.

This discussion has been archived. No new comments can be posted.

Simple Find Files Script

Comments Filter:

When a Banker jumps out of a window, jump after him--that's where the money is. -- Robespierre