Off topic:comparing 2 intergers inside an if statement in bash
0
0
Entering edit mode
5.5 years ago
James ▴ 20

Hi there Can anyone hlep me please?

I am using a bash script to look at fasta files output by another script that makes a new consensus sequence from Illumina sequencing data.

I have 2 potential correct expected outcomes, either a new consensus that is 1 fasta sequence, or 8 fasta sequences. If it is anything else I just want to exit the scipt.

So I'm intending to count up the number of > in my fasta file, if the outcome is 1 or 8 then carry on, if its any other number exit.

I'm just not able to make my if statement do what i want, maybe it's just not possible. I've started along these lines

numseqs=$(grep -o ">" "$infile" | wc -l)

    if [ "$numseqs" -ne 1 OR 8 ] ; then
echo Number of sequences is NOT 1 or 8
exit
else
echo you have 1 or 8 sequences in your fasta file

carry on and run more commands
fi

After some googling Ive tried -ne 1 OR 8, -ne 1 | 8, -ne 1 || 8, -ne 1 && 8, but i'm pretty lost. Any help please?

Thank you James

bash if variable • 732 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 1569 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6