【发布时间】:2009-03-06 16:25:06
【问题描述】:
如果用户主目录超过一定大小,我正在尝试编写一个 shell 脚本来执行操作。不幸的是,当我尝试使用 read 命令拆分 du -s 输出时,我得到“找不到命令”,因为它试图将数字传递给 shell,而不是像我想要的那样传递给变量。这是我目前所拥有的脚本。
#!/bin/bash
cd /home
for i in `ls`
do
j=`du -s $i`
#this line gives me the error
k=`$j |read first;`
done
我得到如下输出:
./takehome.sh: line 6: 3284972: command not found
其中 3284972 是目录的大小。
【问题讨论】: