sort files greater than 1000 bytes in descending order

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I can sort the files either in descending order (of any size) or list all files greater than 1000 bytes but don't know how to sort files greater than 1000 bytes in a user specified directory.
List files greater than 1000 bytes :
for i in "$1/*" # $1 expects a directory name
do
if [ `wc -c $i` -gt 1000 ]
echo $i
done
List files in descending order of size :
`ls -lhS`
But how do I list all files greater than 1000 bytes in descending order of size?
shell-script bourne-shell
add a comment |Â
up vote
0
down vote
favorite
I can sort the files either in descending order (of any size) or list all files greater than 1000 bytes but don't know how to sort files greater than 1000 bytes in a user specified directory.
List files greater than 1000 bytes :
for i in "$1/*" # $1 expects a directory name
do
if [ `wc -c $i` -gt 1000 ]
echo $i
done
List files in descending order of size :
`ls -lhS`
But how do I list all files greater than 1000 bytes in descending order of size?
shell-script bourne-shell
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I can sort the files either in descending order (of any size) or list all files greater than 1000 bytes but don't know how to sort files greater than 1000 bytes in a user specified directory.
List files greater than 1000 bytes :
for i in "$1/*" # $1 expects a directory name
do
if [ `wc -c $i` -gt 1000 ]
echo $i
done
List files in descending order of size :
`ls -lhS`
But how do I list all files greater than 1000 bytes in descending order of size?
shell-script bourne-shell
I can sort the files either in descending order (of any size) or list all files greater than 1000 bytes but don't know how to sort files greater than 1000 bytes in a user specified directory.
List files greater than 1000 bytes :
for i in "$1/*" # $1 expects a directory name
do
if [ `wc -c $i` -gt 1000 ]
echo $i
done
List files in descending order of size :
`ls -lhS`
But how do I list all files greater than 1000 bytes in descending order of size?
shell-script bourne-shell
shell-script bourne-shell
asked Sep 27 '17 at 5:17
Mayank Kumar
1031
1031
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
Try this:
find . -maxdepth 1 -size +1000c -type f -exec ls -lhSa '' +
Explanation:
-maxdepth 1 - find files only in current directory
-size +1000c - find only files greather than 1000 bytes ("c" = bytes)
-type f - find only files
-exec <command> + - execute command. See man find for more information
If you do not want to use find (i don't know why), you may type (thx @ñÃÂsýù÷):
ls -lpSa | awk '! /// && $5>1000'
But Why not parse ls?
No needgrephere, you can get it withawkitselfls -lpSa| awk '! /// && $5>1000'+ Please don't parse ls output.
â Ã±ÃÂsýù÷
Sep 27 '17 at 7:39
@ñÃÂsýù÷ thx alot. I added this into a post
â Egor Vasilyev
Sep 27 '17 at 7:46
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Try this:
find . -maxdepth 1 -size +1000c -type f -exec ls -lhSa '' +
Explanation:
-maxdepth 1 - find files only in current directory
-size +1000c - find only files greather than 1000 bytes ("c" = bytes)
-type f - find only files
-exec <command> + - execute command. See man find for more information
If you do not want to use find (i don't know why), you may type (thx @ñÃÂsýù÷):
ls -lpSa | awk '! /// && $5>1000'
But Why not parse ls?
No needgrephere, you can get it withawkitselfls -lpSa| awk '! /// && $5>1000'+ Please don't parse ls output.
â Ã±ÃÂsýù÷
Sep 27 '17 at 7:39
@ñÃÂsýù÷ thx alot. I added this into a post
â Egor Vasilyev
Sep 27 '17 at 7:46
add a comment |Â
up vote
3
down vote
accepted
Try this:
find . -maxdepth 1 -size +1000c -type f -exec ls -lhSa '' +
Explanation:
-maxdepth 1 - find files only in current directory
-size +1000c - find only files greather than 1000 bytes ("c" = bytes)
-type f - find only files
-exec <command> + - execute command. See man find for more information
If you do not want to use find (i don't know why), you may type (thx @ñÃÂsýù÷):
ls -lpSa | awk '! /// && $5>1000'
But Why not parse ls?
No needgrephere, you can get it withawkitselfls -lpSa| awk '! /// && $5>1000'+ Please don't parse ls output.
â Ã±ÃÂsýù÷
Sep 27 '17 at 7:39
@ñÃÂsýù÷ thx alot. I added this into a post
â Egor Vasilyev
Sep 27 '17 at 7:46
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Try this:
find . -maxdepth 1 -size +1000c -type f -exec ls -lhSa '' +
Explanation:
-maxdepth 1 - find files only in current directory
-size +1000c - find only files greather than 1000 bytes ("c" = bytes)
-type f - find only files
-exec <command> + - execute command. See man find for more information
If you do not want to use find (i don't know why), you may type (thx @ñÃÂsýù÷):
ls -lpSa | awk '! /// && $5>1000'
But Why not parse ls?
Try this:
find . -maxdepth 1 -size +1000c -type f -exec ls -lhSa '' +
Explanation:
-maxdepth 1 - find files only in current directory
-size +1000c - find only files greather than 1000 bytes ("c" = bytes)
-type f - find only files
-exec <command> + - execute command. See man find for more information
If you do not want to use find (i don't know why), you may type (thx @ñÃÂsýù÷):
ls -lpSa | awk '! /// && $5>1000'
But Why not parse ls?
edited Sep 27 '17 at 7:44
answered Sep 27 '17 at 5:34
Egor Vasilyev
1,792129
1,792129
No needgrephere, you can get it withawkitselfls -lpSa| awk '! /// && $5>1000'+ Please don't parse ls output.
â Ã±ÃÂsýù÷
Sep 27 '17 at 7:39
@ñÃÂsýù÷ thx alot. I added this into a post
â Egor Vasilyev
Sep 27 '17 at 7:46
add a comment |Â
No needgrephere, you can get it withawkitselfls -lpSa| awk '! /// && $5>1000'+ Please don't parse ls output.
â Ã±ÃÂsýù÷
Sep 27 '17 at 7:39
@ñÃÂsýù÷ thx alot. I added this into a post
â Egor Vasilyev
Sep 27 '17 at 7:46
No need
grep here, you can get it with awk itself ls -lpSa| awk '! /// && $5>1000' + Please don't parse ls output.â Ã±ÃÂsýù÷
Sep 27 '17 at 7:39
No need
grep here, you can get it with awk itself ls -lpSa| awk '! /// && $5>1000' + Please don't parse ls output.â Ã±ÃÂsýù÷
Sep 27 '17 at 7:39
@ñÃÂsýù÷ thx alot. I added this into a post
â Egor Vasilyev
Sep 27 '17 at 7:46
@ñÃÂsýù÷ thx alot. I added this into a post
â Egor Vasilyev
Sep 27 '17 at 7:46
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394672%2fsort-files-greater-than-1000-bytes-in-descending-order%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password