I'm writing a script to analyse some data. I have several subset of files, and I would like to count the line from these files and write the result into a csv file. I'll try to do an example. I have these two subset of file:
sample1.ext sample1.ext2 sample1.ext3 sample2.ext sample2.ext2 sample2.ext3
I would like to count the lines contained in all the files in
*.ext3 and write the results into a csv file that seems to this:
count(sample1.ext), count(sample1.ext2), count(sample1.ext3) count(sample2.ext), count(sample2.ext2), count(sample2.ext3)
After counting the first series of file in
*.ext, I output the results to the first column of a csv file. How do I write the output of the second count series of
*.ext2 into the second column of the same csv file? And the same for the third column?
Thank to everybody for the answers, I was trying to adapt them to my files, but unfortunately I cannot do it. The example that I posted was just an example, where I put numbers instead of weird extensions to be easiest to understand the problem. You all understood, but you focused too much on the numbers that do not exist in the reality. I will explain you again using the real files. These files are coming from a mapping of genomic data to a reference genome. I treat these data to clean them, so I have three steps where the number of lines changes. So the file are:
name.sort.bam name.mapped.bam name.rmdup.bam othername.sort.bam othername.mapped.bam othername.rmdup.bam
The extension bam is a compressed file. To count the lines in this file, there is a special command line:
samtools view -c (file)
The only way I found was to iterate into each
*rmdup.bam and write a txt output for each, and paste them at the end in a csv file. Is there a way to avoid these three loop and do averything together?
Sorry for the misunderstanding, you all got great ideas!