0

In my working directory, I have a number of subfolders:

SNPsplit_HS_10k_thrs3
SNPsplit_HS_1k_thrs3
SNPsplit_HS_5k_thrs3
SNPsplit_slidingwindow_1000_thrs3
SNPsplit_slidingwindow_100_thrs3
SNPsplit_slidingwindow_2500_thrs3
SNPsplit_slidingwindow_250_thrs3
SNPsplit_slidingwindow_5000_thrs3
SNPsplit_slidingwindow_500_thrs3

I want to know how many files are in each of these directories. If I use something basic like ls -1 SNPsplit_HS_* | wc -l, ls will show the contents of all the SNPsplit_HS_ subdirectories, and then give me the number of lines of that output. I would rather like to see something similar to

SNPsplit_HS_10k_thrs3: 1700
SNPsplit_HS_1k_thrs3: 4200
SNPsplit_HS_5k_thrs3: 2600

Do I need ot use a loop here? Also, is there a way to filter dir/file/symlink? If I wanted to look at *.vcf files in each directory, how would I go about?

Whitehot
  • 133
  • 5
  • See [this answer](https://superuser.com/a/1687310/432690). – Kamil Maciorowski Jan 13 '23 at 13:36
  • @KamilMaciorowski This has a lot of interesting info, in particular about different ways to find specific elements, but my main is issue is with the recurisve/loop nature of what I am trying to do – Whitehot Jan 13 '23 at 13:50
  • look at `find`. – Ljm Dullaart Jan 13 '23 at 18:29
  • "recurisve/loop nature of what I am trying to do" – I see a place for a loop here, but what exactly do you mean by "recursive nature"? `ls -1` you used *does not* work recursively. "Recursive" may mean the number you want to get for `SNPsplit_HS_10k_thrs3` is the total count of files in this directory *and* its subdirectories, deeper and deeper, as deep as it takes. Or "recursive" may mean you want a line of output for `SNPsplit_HS_10k_thrs3` and a separate line of output for `SNPsplit_HS_10k_thrs3/dirA`, `SNPsplit_HS_10k_thrs3/dirB` and so on. Please [edit] and clarify. – Kamil Maciorowski Jan 14 '23 at 20:57

0 Answers0