0

Example :

find /sdcard/ \( -iname '*.gif' -o -iname '*.sh' \) -exec ls -l {} \;
-rw-rw---- root     sdcard_r      552 2016-01-11 02:31 scr.sh
-rw-rw---- root     sdcard_r       12 2017-06-20 09:44 2.gif

will print scr.sh and 2.gif with no full pathes? How print this with full pathes like

-rw-rw---- root sdcard_r 552 2016-01-11 02:31 /sdcard/scr.sh

or something ?

3
  • 1
    Possible duplicate of Absolute path with ls?
    – Lenniey
    Jul 18, 2017 at 8:40
  • 1
    not exactly duplicate , i think
    – ilw
    Jul 18, 2017 at 13:03
  • Works fine for me: find /boot/ -name "*default" -exec ls -l {} \; gives -rw-r--r-- 1 root root 7241840 Jul 22 05:01 /boot/vmlinuz-4.11.8-2-default
    – sebix
    Aug 6, 2017 at 7:42

3 Answers 3

3

What you have should work - for example:

Linux (Ubuntu 16.04)

$ find /var/www/html -type f -exec ls -l {} \;
-rw-r--r-- 1 root root 6 Nov 29  2016 /var/www/html/index.html

Linux (CentOS 7)

$ find ~/ -iname '*.txt' -exec ls -l {} \;
-rw-rw-r-- 1 craig craig 0 Jul 18 08:33 /home/craig/1.txt
-rw-rw-r-- 1 craig craig 0 Jul 18 08:33 /home/craig/2.txt

Mac (10.11.6)

$ find ~/Desktop \( -iname '*.txt' -o -iname '*.localized' \) -exec ls -l {} \;
-rw-r--r--  1 craig  staff  0 13 May  2016 /Users/craig/Desktop/.localized
-rw-r--r--  1 craig  staff  0 18 Jul 09:29 /Users/craig/Desktop/file.txt
2
  • My fall, i'm try before in Android shell. With toolbox ls - print no pathes, with busybox ls - all fine. Hmm. Thanks.
    – ilw
    Jul 18, 2017 at 8:42
  • Another problem. If find print folder - ls print list in folder. How avoid this without -type f ?
    – ilw
    Jul 18, 2017 at 8:44
0

Simply with -ls subcommand:

find /sdcard/ \( -iname '*.gif' -o -iname '*.sh' \) -ls
0

If you're in the directory where you want to search from, subbing in pwd will make find print full paths. E.g:

cd /sdcard/
find $(pwd) \( -iname '*.gif' -o -iname '*.sh' \)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .