Click here to Skip to main content
15,886,816 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Write and submit a script that loops through the values 1-10 in order to produce the following output using only 3 conditional statements (combining conditionals with and/or counts as 1) and 3 echo commands

2 == 2
4 is between 3 and 7
5 is between 3 and 7
6 is between 3 and 7 
10 > 6 


What I have tried:

Bash
#!/bin/bash

for i in {1..3}; do
	if [ $i == 2 }; then
		echo "$i == 2"
	fi 
		for j in {4..6}; do
			if [ $i !is between 3 and 7 ]
	done 
	 for i in {10}; do
		if [ 10 -gt 6 ]
	done 		
Posted
Comments
Sandeep Mewara 20-Oct-20 1:33am    
And your query is?
Yolanda Estrada 20-Oct-20 1:43am    
I know I am missing several steps or so to get the correct output.
Richard MacCutchan 20-Oct-20 3:59am    
You only need a single loop with the different if statements to test for the values in the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900