Question from the Bash - Fundamentals test

Write a Bash script that counts the number of lines in all text files in the current directory.

Medium

What does the following script do?

#bin/bash

counter=0

for file in ./*.txt
do
  line=$(wc -l $file | cut -d" " -f1);
  counter=$(($counter+$line))
done
echo "$counter"
Author: titouan lecampStatus: PublishedQuestion passed 150 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!