I have a bunch of files, and I would like to see how many columns a file has for all of the files with a certain name. So after reading around in the forum, I wrote the code below, but it doesn't print out the file name. Could somebody kindly point out the problem for me please? Thanks a lot in advance!
for file in $(find ./ -name "*_intersect.txt")
do
name=$(basename $file)
awk -v var="$name" '{print name,NF; exit}' $file
done
the expected output could be
file1 4
file2 8
file3 5