Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
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:

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

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:

I've never been canoeing before, but I imagine there must be just a few simple heuristics you have to remember... Yes, don't fall out, and don't hit rocks.

Working...