我想从文件中删除所有空行。即使该行包含空格或制表符,也应将其删除。
为什么以下脚本给出的计数为 0 而不是给出目录中存在的文件计数?
#!/bin/bash
cd /root/Jamshed/script
count=0
ls -lrt > all_files
cat all_files | while read dir
do
count=$(($count + 1))
done
echo $count;
Run Code Online (Sandbox Code Playgroud)