My assignment is: Find files (in a specific directory that is given) , show only the ones above 100 megabytes, sort them by size, print them in ls -lh format.
This is what I execute:
find /home/it21366 -size +10M | sort -h | ls -lh
This is what I get
-rwxr-xr-x+ 1 it21366 unixusers 12K Απρ 28 2014 a.out
-rwxr-xr-x+ 1 it21366 unixusers 471 Νοέ 29 10:51 askisi.sh
-rw-r--r--+ 1 it21366 unixusers 3,0K Απρ 28 2014 code.c
-rw-r--r--+ 1 it21366 unixusers 3,0K Απρ 28 2014 code.c~
-rw-r--r--+ 1 it21366 unixusers 6,2K Απρ 28 2014 CODE.txt
-rw-------+ 1 it21366 unixusers 2,0M Απρ 28 2014 core
-rwxr-xr-x+ 1 it21366 unixusers 66 Δεκ 6 14:39 it21366_ex_1_1
-rwxr-xr-x+ 1 it21366 unixusers 190 Δεκ 6 14:35 it21366_ex_1_4.sh
-rwxr-xr-x+ 1 it21366 unixusers 190 Δεκ 6 14:27 it21366_ex_1_4.sh~
-rwxr-xr-x+ 1 it21366 unixusers 546 Δεκ 5 17:46 it21366_ex_1_5
-rw-r--r--+ 1 it21366 unixusers 509K Οκτ 23 2014 java01.pdf
-rw-r--r--+ 1 it21366 unixusers 506K Οκτ 23 2014 java02.pdf
-rw-r--r--+ 1 it21366 unixusers 249K Οκτ 11 10:03 lab01_2018-19.pdf
-rw-r--r--+ 1 it21366 unixusers 1,2K Οκτ 24 16:27 MyClock.java
-rw-r--r--+ 1 it21366 unixusers 1,3K Οκτ 30 2013 starthere.desktop
-rw-r--r--+ 1 it21366 unixusers 3 Οκτ 24 12:45 test
-rw-r--r--+ 1 it21366 unixusers 12 Οκτ 24 12:45 TK.txt
-rw-r--r--+ 1 it21366 unixusers 14K Μάι 30 2018 Untitled 1.odt
I can't imagine why LS seems to ignore the other methods, and simply shows the contents of the files unsorted and unfiltered.
ls
does not use anything you're trying to pipe to it through standard input. Since its command line arguments are just the options-lh
, it's listing the full contents of the current directory, in long format with human-optimized file sizes, in default alphanumeric sort order. You would need different options forls
to sort in different ways, e.g. by size, or to display the directory list unsorted. – telcoM Dec 06 '18 at 12:56ls
Not Working as Expected – steeldriver Dec 06 '18 at 13:00