I have the command
sudo find / -size +450M -exec ls -lhGSr {} \;
to find and list files greater than 450M. I know how to display the output in zenity, but I'd like to select a path (any) in zenity output, then double click and this path is opened in a File Manager (in my case in Thunar). How can I achieve that?
Although it is possible to do that, you should keep in mind that it will waste time looking in directories such as
/sys
,/proc
and/dev
, which you should probably leave alone.That said, this little script does what you asked for:
find
is executed with privileges, but Zenity is run as your normal user (graphical applications should not be run as root). When the first line finishes you are presented the Zenity dialog. Since you need to provide the directory which contains the selected file as an argument tothunar
, I extract it withdirname
.In general, you create a selection list in
zenity
as in the following example, where the files in the current folder are listed:This command will display a zenity dialog with the output of the
ls
command. When an item is selected, it is printed to standard out.You can combine commands such that action is directly taken on the output of
zenity
as following:Specifically for XFCE, you may prefer to use
exo-open
insteadxdg-open
.