Find command confusion ???
Hello
I want to find files that are less than 1 MiB. Following is the actual list of files: Code:
$ ls -lS Code:
$ find . -size -$((1*1024*1024))c -ls But when I use -exec option, why I'm getting this output? Code:
$ find . -size -$((1*1024*1024))c -exec ls -l "{}" + How do I correct this? Thanks |
Quote:
Then, the -exec as YOU did it will also work on subdirectories, as they're (almost always) smaller then 1M. So either put an extra "-type f" in the find or an extra option -d in the ls -l (to show directories AS directories, not as their contents). Finally the string {} doesn't need to be quoted. See the section about "-execdir" too in the man page for find. |
Thanks
Quote:
Quote:
|
Quote:
Quote:
I don't think find will go into .., though. BTW: find's -ls option is equivalent to ls -dils, so with i-nodes and size in blocks added. |
The $(()) only takes two parameters, for three you'd have to nest $(()), so $(( 1 * $(( 1024 * 1024 )) ))c. Or I could be wrong.
|
Odd, the "-type f" as previous suggested helps. Without it the -size seemed to get ignored. For me anyway.
$ find ./ -size $(( -1 * 50 ))k -type f 2>&1 | while read FILE; do ls -l $FILE; done The while read just to have ls -l output to show file size. Probably a way for find to output that, and not efficient my way. I just wanted it to verify results. I could have sworn that $(( )) needed nesting, maybe a versioning quirk. Or an old programmer mental block having started on assembler where nothing took more than two parameters (or used to at least). In either case, probably better to multiply with a leading negative number for a - prefixed result. The - prefixed arithmetic operation might be interpreted as a bad parameter, than a value to a parameter. Probably just another programmer mental block though, as it seems to work regardless. |
edit: NM. I see you corrected yourself. Sorry for the noise.
|
Quote:
|
Quote:
Code:
$ echo "$(( 1 * 1024 * 1024 ))" |
All times are GMT -5. The time now is 11:43 PM. |