×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Simple Find Files Script

thePsychologist (1062886) writes | more than 6 years ago

Data Storage 0

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.

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.

0 comment

Check for New Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Sign up for Slashdot Newsletters
Create a Slashdot Account

Loading...