Sorting recursive 'ls' and 'grep'
If you do for instance the following:
Code:
ls -RSl images | grep '.gif' Is there any way to sort in a consolidate fashion? Where the recursion to gather the file data is done first, and then all files are sorted together? |
Could this work for your situation?
$ find . -iname '*.gif' -exec basename {} \; | sort i.e. Find the .gifs, get the basename (filename minus directory), then pipe it all to sort. |
Do you want to sort simply by the basename? You could use find instead. This example prints two entries per file, the basename and the full pathname and then uses sort to sort the output:
Code:
find ./ -type f -printf "%f\t%p\n" | sort |
Code:
find . -iname \*gif -ls | sort -k 7,7 -k 11,11 Finds all, sorts by size, then directory/name Cheers, Tink |
Quote:
Code:
find ./ -iname '*.gif' -type f -printf "%s\t%p\n" | sort -r -n Code:
find ./ -iname '*.gif' -type f -printf "%T@\t%t\t%p\n" | sort -r -n Quote:
I prefer the find...-ls format to using -printf, but can -ls format be done with raw file size rather than file size in 1K blocks? And is there any way to use the -ls format to sort by modification change time/status change time etc.? |
In that case all you need to do is to invoke the *real* ls rather that using
finds built-in one. re-apply your -r to sort where ever needed ;} Code:
find . -iname \*gif -exec ls -lc {} \;| sort -k 7,7 -k 11,11 Cheers, Tink |
All times are GMT -5. The time now is 03:46 AM. |