Fast search ‘n sorting on my fileserver

Last Updated or created 2023-01-05

When i’m looking for certain files on my fileserver i sometimes have to fallback to locate.

Most of the times i use the methods mentioned in :

The script below helps me to copy located files to a temporary directory.
(Which is excluded in al kinds of other find tools)

It will remove the slashes in a path, but keeps the rest.

  • You can pipe to this script
  • All files in 1 directory, but NO overwrite of files (keeps path). This allows for easy browsing with a picture viewer.
  • Want to know original path, look at the filename .. think of where the slashes should go


Lets find all jpg’s which linux in its name

# this will list all found files
locate -i linux | grep -i jpg$ 

output example (see below) (With slashes and spaces)
/tank/WorkDirectory/TMP/UITZOEKEN/cds uitzoeken/div/141/31/cd3/done/gfx/linux-from-scratch.jpg


mkdir -p /mnt/private/TEMP/$$
cat - | while read line ; do cp "$line" /mnt/private/TEMP/$$/$(echo "$line" | tr -cd 'A-Za-z0-9._-' ; echo "" ) ;done

When running combined command:

locate -i linux | grep -i jpg$ | cplocatescript

It will create a directory like below

ls /mnt/private/28723/
etc ...
etc ...
etc ...
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *