Running a command for all files whose name matches…

I found a stray image named “img_1234.jpg” on a laptop and wanted to see if I already had it on my server.

On my Mac I could use spotlight’s nifty “kind:image” filter along with quicklook. Macworld has a great article about advanced spotlight usage.

On Ubuntu, it’s almost as easy:

locate -i img_1234.jpg | xargs -d'\n' feh -F -d
  • The locate -i says “find img_1234.jpg without case sensitivity. Locate likes to separate filenames (that might have spaces) with a newline.
  • The xargs -d'\n' says “expect filenames that are are separated by newline
  • The feh -F -d tells feh, a great little image viewer, to reduce the image to fit to the screen and draw the filename.

Related posts:

  1. Dealing with a directory with ~∞ files
    Got a directory with > 10K of files? Need to move them up one directory? mv will fail you: $ mv * .. -bash: /bin/mv: Argument list too long The......
  2. Recursive sort-by-modification-time
    This certainly isn’t rocket science, but it also is certainly not something you want to type more than once. find . -type f -printf '%T@\t%p\n' | sort -n | cut......
  3. How to fix the wifi on a HP Mini 110 Netbook running Ubuntu 9.10 (Karmic Koala)
    Installing Karmic Koala from a USB drive proved to be a bit less than effortless. First off the http and ftp servers for the netbook-reloaded ISO images were really slow,......
  4. Simple PHP image rotation script
    This blog has a rotating header — if you visit /header/ and bounce on reload, you’ll see a series of random images. Here’s how it works: The header is added......

This entry was posted in Technical HOWTOs and tagged , , . Bookmark the permalink.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Additional comments powered by BackType