Artificial intelligent assistant

how to print file name and total number of fasta sequences? I have a fasta file namely test.fasta, pas.fasta, cel.fasta as shown below test.fasta >tile ATGTC >259 TGAT pas.fasta >ta ATGCT cel.fasta >787 TGTAG >yog TGTAT >In NNTAG I need to print the file name and the total number of fasta sequences as shown below, test,2 pas,1 cel,3 I have used the following commands but failed to serve my purpose grep ">" test.fasta | wc -l && ls test.fasta Please help me to do the same. Thanks in advance.

That's what the `-c` option of `grep` (to `c`ount) is for:


$ grep -ce '^>' -- *.fasta
cel.fasta:3
pas.fasta:1
test.fasta:2


Note that if there's only one matching file, the file name will not be printed. Some `grep` implementations have a `-H` option to force the file name to be printed always:


$ grep -Hce '^>' -- *.fasta
cel.fasta:3


To get your exact expected output, you just need to replace `.fasta:` with `,`:


$ grep -Hce '^>' -- *.fasta | sed 's/\.fasta:/,/'
cel,3
pas,1
test,2


(here assuming your file names don't contain other occurrences of `.fasta:` such as `my.fasta:foo.fasta`; of course newline or `,` or `"` characters and potentially whitespace characters in file names would also be a problem if the output is meant to be in CSV format)

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 2ca0c97f3404e7b178345d6cabe50b1c