2014-09-24 93 views
1

是否有方法或參數讓bash命令「ls」顯示位上的文件大小? 我知道「ls -lh」會顯示其大小的文件,但以字節,千字節等表示。 或者任何其他可用於Linux的bash命令?以ls爲單位的文件大小?

+0

的跨網站重複http://unix.stackexchange.com/questions/111049/ how-do-one-find-out-how-many-bits-a-file-has-in-one-command – blackSmith 2014-09-24 05:50:35

回答

4

這工作在Linux中

ls -l | awk '{$5=$5*8; print;}' 
+0

似乎是最短的做法,謝謝 – JoseMiguel 2014-09-25 04:18:08

+0

下面是一個較短的方法:'ls -l | awk'{$ 5 = $ 5 * 8} 1'' – 2016-02-05 19:42:08

1

自己寫的功能,一些在這個方向:

for file in *; do 
    [[ -d "$file" ]] && continue 
    printf "%12u\t%s\n" "$(($(wc -c < "$file") * 8))" "$file" 
done 
+0

..但是假定一個字節是8位......這在univac上是不正確的1108 – Soren 2014-09-24 03:37:41

相關問題