Print full path of files and sizes with find in Linux

32

Solution 1

Instead of -exec ls -lh {} \; you can also use the printf option:

find / \( -path /proc -o -path /sys \) -prune -o -newer /tmp/test -printf "%s %p\n" | less

Although that will just print the size in bytes and not in the nice human-readable format ls supports.

Solution 2

Add -d to the ls command.

find / \( -path /proc -o -path /sys \) -prune -o -newer /tmp/test -exec ls -lhd {} \; | less

That will also fix the problem you were bound to have with files showing up twice in your list.

Share:
32

Related videos on Youtube

Tiit Papp
Author by

Tiit Papp

Updated on September 18, 2022

Comments

  • Tiit Papp
    Tiit Papp over 1 year

    If there was only a one-level menu tree, activating and deactivating links would not be a problem.

    <ul class="sidemenu">
     <li class="active"><a href="#">some title</a></li>
     <li><a href="#">some title</a></li>
     <li><a href="#">some title</a></li>
     etc ...
    </ul>
    
    $('.sidemenu').on('click', 'li', function() {
        $('.sidemenu li.active').removeClass('active');
        $(this).addClass('active');
    });
    

    I needed to solve the activation / deactivation of each link in the two-level menu tree, but I did not find the correct or working solution. I understand very well that this jquery code is suitable for a one-level menu.

    I was looking everywhere for some good clues. My head is empty.

    My jsfiddle code is here: https://jsfiddle.net/kukrik/d3pcrhnm/15/.

    I would be very grateful if anyone has good advice or experiences to share.

  • l0b0
    l0b0 almost 11 years
    +1 for POSIX and non-ls solution.
  • vonbrand
    vonbrand over 4 years
    The day you need to use some other system or user, it will bite you.
  • Tiit Papp
    Tiit Papp about 4 years
    Many thanks to Çağrı! Often a seemingly big problem turns out to be very simple. I once thought about this possible solution. It was this Css code that blocked my normal thinking. Here is a working example: jsfiddle.net/kukrik/gzodabnm/11