with seqkit:
input:
$ cat test.fa
>Sample1
tctctccttt
>Sample2
tctctcattt
>Sample3
tctctccttt
>Sample1
tctctccttg
output:
$ seqkit rmdup test.fa --quiet
>Sample1
tctctccttt
>Sample2
tctctcattt
>Sample3
tctctccttt
Download seqkit from here
with case insensitive awk line, modified from one of the answers here. Upvote the OP):
$ awk '/^>/ {if (!a[tolower($0)]++) {print;getline;print}}' test.fa
>Sample1
tctctccttt
>Sample2
tctctcattt
>Sample3
tctctccttt
>sample4
ctga
input fasta:
>Sample1
tctctccttt
>Sample1
atgc
>Sample2
tctctcattt
>Sample3
tctctccttt
>Sample1
tctctccttg
>sample1
ttgc
>sample2
atgc
>sample4
ctga
>Sample2
tct
if you want random sequence every time, from fasta with duplicated IDs (case insensitive):
$ seqkit fx2tab test.fa | datamash -sig 1 rand 2 | seqkit tab2fx
If the sequences themselves aren't unique, how do you know which sequence you want to keep for those with duplicated names?
I could quickly throw together a python script that will do what you're asking, but maybe someone has a quicker solution.
The short answer is it doesn't matter which one I keep.
By the way, the reason your
grep | uniq -cdid not work is because you need to sort before piping to uniq. So: