SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-07-18 08:41:15

ThreepWood
#! Member
Registered: 2009-02-12
Posts: 68

bashscript (?) to pipe found pictures to an image viewer

Hellow there fellow crunchbangers...i hope somebody can lighten me up.

What i'm trying to achieve is to submit a search with

find ~/ -name "*.jpg" | gpicview 

to pipe the results to gpicview...
Obviously this doesn't work (or else i wouldn't be posting).

My question is, how to do such a thing? Pipe results from a search to see the pictures with some image-viewer? Whitout the need to copy them before to a temp directory, of course.

Anybody knows a method? Any ideas?

Would be a for...loop in the search results a better way to do it?
As i'm still newbee with the command line, all replies are welcome.

Thank You for Your attention.


...selfmade-wannabee #!in' pirate. Arrr!

Offline

Help fund CrunchBang, donate to the project!

#2 2010-07-18 13:09:17

anonymous
The Mystery Member
From: Arch Linux Forums
Registered: 2008-11-29
Posts: 9,418

Re: bashscript (?) to pipe found pictures to an image viewer

Try this:

gpicview `find ~/ -name "*.jpg"`

Offline

#3 2010-07-21 04:52:32

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 3,265
Website

Re: bashscript (?) to pipe found pictures to an image viewer

The problem is gpicview only takes one argument.  ( Once you've opened an image you can browse to all the other images in that folder though. )

In general, to send the results of a "find" search to some program you can use "xargs" like this:

 find -name '*.txt' -print0 | xargs -0 gedit

will open all the *.txt files in tags in gedit. (The -print0 and -0 options are to protect you from files with spaces or newlines in their names.)


John     Please help us keep your forums manageable.
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#4 2010-07-21 07:20:18

luc
#! Die Hard
From: Munich, Germany
Registered: 2010-03-21
Posts: 597

Re: bashscript (?) to pipe found pictures to an image viewer

what about :

find ~/ -name "*.jpg" | while read line
do
gpicview $line &
done

this should open each match in a new window

Offline

#5 2010-07-21 14:55:37

benj1
Wiki Wizard
From: Yorkshire, England
Registered: 2009-09-05
Posts: 1,084

Re: bashscript (?) to pipe found pictures to an image viewer

gpicview will automatically show pictures added to its current directory so

mkdir /tmp/pictures
for PIC in $(find ~/ -name *.jpg); do 
    ln -s $PIC /tmp/pictures  ( or if you prefer cp $PIC /tmp/pictures)
done
gpicview /tmp/pictures/*
rm -r /tmp/pictures

untested but should work, you'll only get one instance of gpicview.


- - - - - - - - Wiki Pages - - - - - - -
#! install guide           *autostart programs, modify the menu & keybindings
configuring Conky       *installing scripts

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo