I have a single line find command, which recursively checks and prints out the size, owner and name of a specific file type which are created in a specific time frame. But in the result, the filename column is given until the first space character in the directory or file name. Any idea to fix this problem right in this single command without writing any loop in the bash? Thanks!
here is the command:
find /path/to/dist -type f -iname "*.png" -newermt 2015-01-01 ! -newermt 2016-12-31 -ls | sort -k5 | sort -k5 | awk '{print $5"\t"$7"\t"$11}'
Well thanks to Arno's input, the following line does the job. I used exec (
-exec ls -lh {} \;
) to make the size human readable:Try changing your
awk
command to this :So that the whole command becomes this :
This leaves some extra spaces at the beginning of the line, hopefully it works for your purpose.
I have removed the second instance of
sort
, as it sorts on the same key as the first, which does not seem likely to do anything.I found the following solution. You hide the space in filename. I did it with a sed, I used a strange chain "!!!" to replace "\ ". Then I replace it in awk command. Here is the command I used for my tests:
The
-print0
action offind
is probably the starting point. From find's manual page:But
find
has the niceprintf
action that is even better:probably does the job.