Question from the Bash - Fundamentals test

How to count the number of lines in a file in Bash

Hard

In the following script:

#bin/bash

counter=0

for file in ./*.txt
do
  line=$(wc -l $file | cut -d" " -f1);
  counter=$(($counter+$line))
done
echo "$counter"

What does the cut -d" " -f1 part do?

Author: titouan lecampStatus: PublishedQuestion passed 149 times
Edit
1
Community Evaluations
developer avatar
Houssem
07/04/2022
L'énoncé est faux!! Il ne colle pas avec les réponses du QCM.
developer avatar
Auteur anonyme
12/04/2022
Bonjour Houssem, après vérification les réponses semblent correctes. Peux-tu proposer une alternative ?