[opensuse] list of directories containing a specific file type
Hello: I would like to search for all the directories containing files with jpg extension (*.jpg) on my system. The output should list only the directory paths, one path only once either it contains one or more *.jpg files. The file names should be omitted. I'd like to do it in a bash terminal. Is this feasible? I looked at the find command but could find how to get the wanted output. Thanks, Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Istvan Gabor wrote:
Hello:
I would like to search for all the directories containing files with jpg extension (*.jpg) on my system. The output should list only the directory paths, one path only once either it contains one or more *.jpg files. The file names should be omitted. I'd like to do it in a bash terminal. Is this feasible? I looked at the find command but could find how to get the wanted output.
Try this: find . -type f -name \*jpg -printf "%h\n" | sort -u -- Per Jessen, Zürich (3.6°C) http://www.hostsuisse.com/ - virtual servers, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
find ... -name "*.jpg" -printf '%h\n' | sort -u
if directory names can contain new lines themselves you may consider
separating file names with \0 and using "sort -uz" instead.
On Fri, Jan 15, 2016 at 2:02 PM, Istvan Gabor
Hello:
I would like to search for all the directories containing files with jpg extension (*.jpg) on my system. The output should list only the directory paths, one path only once either it contains one or more *.jpg files. The file names should be omitted. I'd like to do it in a bash terminal. Is this feasible? I looked at the find command but could find how to get the wanted output.
Thanks,
Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Andrei Borzenkov írta:
find ... -name "*.jpg" -printf '%h\n' | sort -u
if directory names can contain new lines themselves you may consider separating file names with \0 and using "sort -uz" instead.
On Fri, Jan 15, 2016 at 2:02 PM, Istvan Gabor wrote:
Hello:
I would like to search for all the directories containing files with jpg extension (*.jpg) >>on my system. The output should list only the directory paths, one path only once >>either it contains one or more *.jpg files. The file names should be omitted. I'd like to >>do it in a bash terminal. Is this feasible? I looked at the find command but could find >>how to get the wanted output.
Per, Andrei: Thanks, the command works nicely. Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (3)
-
Andrei Borzenkov
-
Istvan Gabor
-
Per Jessen