如何存储来自$find的搜索结果计数。- 名称 Unix 中的"*.txt"



我无法存储Unix中的搜索结果计数,以便我可以在其他表达式中使用变量

$find . -name "*.txt"
$  find . -name “*.txt” | wc -l   # count the lines 
$  var=$(find <expr>|wc -l)

另一种方式不简单地与GNU查找。

nbfile=$(2>&1 find -D rates . -name "*.txt" 1>/dev/null | 
  sed -n '$s/.*/([^=]*).*/1/p')
echo "nbfiles = $nbfile"

最新更新