Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell solaris操作系统中awk中小数点后的汇总_Shell_Unix_Awk_Solaris_Solaris 10 - Fatal编程技术网

Shell solaris操作系统中awk中小数点后的汇总

Shell solaris操作系统中awk中小数点后的汇总,shell,unix,awk,solaris,solaris-10,Shell,Unix,Awk,Solaris,Solaris 10,我想要文件夹中文件的总大小,在sun solaris操作系统中使用以abc_1_*等名称开头的特定文件,因为在这里我不能使用du-ch,当前我正在使用find命令,我正在获得所需的输出,但我希望在小数点后获得四舍五入输出 当前代码:- echo `find $DUMPDIR -name "${DUMPFILE}*" -exec ls -ltr {} \; | awk ' {s+=$5} END {print s/1024/1024/1024}'` 输出:- 1.768932 1.7G

我想要文件夹中文件的总大小,在sun solaris操作系统中使用以abc_1_*等名称开头的特定文件,因为在这里我不能使用du-ch,当前我正在使用find命令,我正在获得所需的输出,但我希望在小数点后获得四舍五入输出

当前代码:-

echo `find $DUMPDIR -name "${DUMPFILE}*" -exec ls -ltr {} \;  | awk ' {s+=$5} END {print s/1024/1024/1024}'`
输出:-

  1.768932
1.7G
期望输出:-

1.7G
请帮助我,我是solaris新手

find $DUMPDIR -name "${DUMPFILE}*" -exec ls -lh {} \; | awk '{print $5}'
您可以使用GNU扩展名
-h
选项
ls
以可读格式打印尺寸。注意:@Andrew Henle建议,
-h
不保证在
ls
中受支持

或者干脆用,

ls -lh "$DUMPDIR/${DUMPFILE}*" | cut -d' ' -f 5
您可以使用GNU扩展名
-h
选项
ls
以可读格式打印尺寸。注意:@Andrew Henle建议,
-h
不保证在
ls
中受支持

或者干脆用,

ls -lh "$DUMPDIR/${DUMPFILE}*" | cut -d' ' -f 5

您可以在
awk
中使用

awk 'BEGIN {fl=1.768932; printf("%.1f G\n", fl)}'

您可以在
awk
中使用

awk 'BEGIN {fl=1.768932; printf("%.1f G\n", fl)}'

您可以直接使用
ls
-h
选项以人类可读的格式打印尺寸。不,你不能
-h
是的GNU扩展,不保证支持它。我得到0 GB的outputecho
find$DUMPDIR-name“${DUMPFILE}*”-exec ls-lh{}\|awk'{s+=$5}END{print s/1024/1024/1024}'
“GB”只需使用
awk'{print$5}'
就足够了。@AndrewHenle,感谢您的信息,我将尝试修改我的答案以突出显示这一点。您可以直接使用
ls
-h
选项以人类可读的格式打印大小。不,你不能
-h
是的GNU扩展,不保证支持它。我得到0 GB的outputecho
find$DUMPDIR-name“${DUMPFILE}*”-exec ls-lh{}\|awk'{s+=$5}END{print s/1024/1024/1024}'
“GB”只要使用
awk'{print$5}'
就足够了。@Andrewenle,谢谢你的信息,我会尝试修改我的答案来突出显示这一点。