Artificial intelligent assistant

Flip-flop in shell In Wikipedia there are two relevant articles about the term "Flip-flop": * Flip-flop (electronics)) * Flip-flop (programming)) I think that there is a formal-logic common denominator between the two issues. I am an amateur sysadmin with some tiny knowledge in Bash which does some system administration only for myself; I have no intention to one day become an electronics engineer, firmware developer or anything like that, but I do want to learn about the general meaning of Flip-flops (electronics/programming) via Bash if this is possible via a primal simple example for newcomers to learn about the term. If indeed there is a formal-logic common denominator between Flip-flops in electronics and Flip-flops in programming, what would be a simple shell (Bash) example?

Aside from sharing the name, I don't think those two concepts have anything to do with one another.

But if you're looking for something in bash that behaves like this Ruby example from the Wikipedia article you linked:


(1..10).each do |x|
puts x if (x == 4 .. x == 6)
end


A version of that in bash is:


#!/bin/bash

do_print="false"
for ((i = 1; i <= 10; ++i)); do
if [[ ${i} -eq 4 ]]; then
do_print="true"
fi

if [[ "${do_print}" == "true" ]]; then
echo "${i}"
fi

if [[ ${i} -eq 6 ]]; then
do_print="false"
fi
done


The `do_print` variable "flips" on when `i=4` and "flops" off when `i=6`. Bash doesn't have the syntactic sugar to do that the way Ruby does.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 12d8b7adddddfa392ffad0ea1b2ff492