How can I make this command run on files only?
du -h * | sort -h -r | head -n 5
Now I am using * which runs on all files and directories but I want to change that.
you need to use the find
utility to pinpoint only the files:
find . -type f -exec du -h {} + | sort -n -r | head -n 5
also you have a typo, it's sort -n -r
not sort -h -r
也许它有帮助
for i in $(ls -d */ | sort -h -r | head -n 5); do du -h $i; done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.