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
Bash 将“du”结果存储在变量中_Bash_Unix_Putty - Fatal编程技术网

Bash 将“du”结果存储在变量中

Bash 将“du”结果存储在变量中,bash,unix,putty,Bash,Unix,Putty,我使用bash-4.2的腻子。其中,我输出的文件大小为: du-m myfile.csv 返回: 1.25 myfile.csv 如何将这一行存储在变量中,以便稍后解析文件大小 提前谢谢就这样吧 FOO="$(du -m myfile.csv)" echo "$FOO" 输出 1.25 myfile.csv 使用本机shell内置varname=$du-m myfile.csv您应该阅读.awesome。我很感激

我使用bash-4.2的腻子。其中,我输出的文件大小为:

du-m myfile.csv

返回:

1.25 myfile.csv

如何将这一行存储在变量中,以便稍后解析文件大小

提前谢谢

就这样吧

FOO="$(du -m myfile.csv)"
echo "$FOO"
输出

1.25 myfile.csv

使用本机shell内置varname=$du-m myfile.csv您应该阅读.awesome。我很感激