← Back to Gists

Sort files by size

📝 Bash
Use this bash snippet to list files sorted by size from largest to smallest.
Bash
#!/bin/bash
listfilessortedbysize() { ls -lS | grep '^-'
}
listfilessortedbysize

Comments

-1
ryan ryan 5d ago
@snek that works for the current dir but if you want to recurse into subfolders you need something like `du -sh | sort -rh` instead.