morse script 2
I'll copy in the actual code below later, but I can't right now because I'm using ssh to a headless machine at work. I gave up on reading the letters from a separate text file - seemed like too much overhead for what I wanted to do. Instead I've found out how to create an associative array within my bash script. This'll let me pass the user input variable as a key that will return the binary value. SO, I have the following: #!/bin/bash # declare array and assign values to each letter # make sure no spaced between array var, = and ( declare -A morseCode_arr=( [a]=01 [b]=1000 [c]=1010 [d]=100 [e]=0 [f]=0010 [g]=110 [h]=0000 [i]=00 [j]=0111 [k]=101 [l]=0100 [m]=11 [n]=10 [o]=111 [p]=0110 [q]=1101 [r]=010 [s]=000 [t]=1 [u]=001 [v]=0001 [w]=011 [x]=1001 [y]=1011 [z]=1100 ) echo 'Input string' read user_input #loop over the characters if the user input for (( s=0; s<${#user_input}; s++ )); do # retrieve the value from the array and assign to a new va...