remove sequences from fasta file matching a string in the header
you may use simple R commands, using the 'seqinr' package

#load package
library(seqinr)
#load file containing sequences
data&lt;-read.fasta("filename.fa")
#create a vector containing species names: these are the last part of the string
vec.names&lt;-unlist(lapply(strsplit(names(data), ";"), function(x)x[length(x)]))
#find names to keep: indices which are not in the species to remove
species.to.remove&lt;-c("species_name1", "species_name2", "species_name4")
vec.tokeep&lt;-which(! vec.names %in%  species.to.remove)
#write the final output
write.fasta(sequences=data[vec.tokeep], names=names(data)[vec.tokeep], file.out="output.fa")