[英]Get size of image in bash
我想獲取圖像的大小。 圖像位於文件夾中,名稱為encodedImage.jpc
a="$(ls -s encodedImage.jpc | cut -d " " -f 1)"
temp="$(( $a*1024 * 8))"
echo "$a"
輸出不正確。 如何獲得尺寸? 謝謝
如果按大小表示字節或漂亮字節,則可以使用
ls -lh
-h When used with the -l option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the number of digits to three or less using base 2 for sizes.
如果您只是想單獨刪除文件大小,我猜想是更完整的答案(我還添加了文件名,您可以刪除,$9
刪除它)
ls -lh | awk '{print $5,$9}'
你可以使用這個命令
du -sh your_file
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.