bash ls 的文件大小(以位为单位)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26006790/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
File size in bits with ls?
提问by JoseMiguel
Is there a way or argument to make the bash command "ls" show the file sizes on bits? I know that "ls -lh" shows the files with its sizes, but in bytes, kilobytes, etc. Or any other bash command for linux that can so that?
有没有办法或参数让 bash 命令“ls”按位显示文件大小?我知道“ls -lh”显示文件的大小,但以字节、千字节等为单位。或者任何其他用于 linux 的 bash 命令可以这样吗?
回答by Vytenis Bivainis
This works in Linux
这适用于 Linux
ls -l | awk '{=*8; print;}'
回答by JoseMiguel
Write your own function, something in this direction:
写你自己的函数,在这个方向上的东西:
for file in *; do
[[ -d "$file" ]] && continue
printf "%12u\t%s\n" "$(( $(wc -c < "$file") * 8 ))" "$file"
done