Script to isolate files with 1 instance of each of 4 diff. words (grep)
Hi all,
I am trying to write a script that searches though a directory of files with the names Moll_10000.fasta to Moll_16000.fasta, searches each file for the number of instances of the following strings: LGIG, HROB, NVEC, and CAP, and copies each file containing only one instance of each word to another folder. I know grep is at least in part the tool for the job and that the {1} modifier should be involved (right?). I can't figure out what to do, though. Here's what I've got so far (some of this is probably unnecessary): Code:
grep -c LGIG\| *.fasta | cat > LGIG_count.txt Thanks! Kevin |
Put the following in a file and give the file execute permission (chmod 744 <file name>
Code:
#!/bin/bash |
From "The Linux cookbook: tips and techniques for everyday use" by Michael Stutz
12.2.3 Listing Only the Unique Words in Text Presuming there is no punctuations in your text files, the tr command could be : tr -s '[:blank:]' '\n' <text |sort|uniq So for solving your specific problem, you can use : Code:
for file in *.fasta; do Maybe some adjustments are to be made, but something along that line may solve your problem. Bye. |
An afterthought, if the *.fasta files are very large you can restrict the tr command to only the lines containing the searched strings :
Code:
for file in *.fasta; do |
All times are GMT -5. The time now is 04:30 PM. |