这是我的小型bash脚本代码,我想打印在目录中创建的文件数:
<div class="card border-success">
<div class="card-horizontal">
<div class="card-body bg-success">
<p class="card-text text-white bg-success text-md-center"><i class="fas fa-users fa-2x"></i></p>
</div>
<div class="card-body text-success">
<p class="card-text">Registered Member: <strong>{{ $userTotal->count() }}</strong></p>
<p class="card-text">Active Members: <strong>{{ $userActive->count() }}</strong></p>
<p class="card-text">Active Members: <strong>{{ $userActive->count() }}</strong></p>
<p class="card-text">Inactive Members: <strong>{{ $userInactive->count() }}</strong></p>
</div>
</div>
</div>
我的预期输出是:
#! /bin/sh
home_dir=/home/var/foo
Count= ls /$home_dir|wc -l
echo -e "$Count files are existed in the directory $home_dir"
exit 0
但是我得到以下输出:
9 files are existed in the directory /home/var/foo
您能帮我上面的代码出什么问题吗?另外,请建议这是否是打印目录中文件数量的正确方法
答案 0 :(得分:0)
这对我有用:
Count=$(ls /$xml_dir|wc -l)
答案 1 :(得分:0)
要在同一行上打印
echo -ne "$Count files are existed in the directory $home_dir"
将参数n添加到回显中。