Using Sed bash Script On Linux To Generate Morse Code Without Sound

Go down

Using Sed bash Script On Linux To Generate Morse Code Without Sound

Post by jamied_uk on 15th July 2016, 01:03

Code:
#!/bin/sed -rf
# https://www.rosettacode.org/wiki/Morse_code#Python
# usage ./morse.sh
# Convert to uppercase
s/.*/\U&/
# Add lookup table
s/$/\nA.-B-...C-.-.D-..E.F..-.G--.H....I..J.---K-.-L.-..M--N-.O---P.--.Q--.-R.-.S...T-U..-V...-W.--X-..-Y-.--Z--../
# Main loop
:a
s/([A-Z])([^\n]*\n.*\1([-.]+))/\3 \2/
ta
# Remove lookup table
s/\n.*//
# echo hello world! | ./morse.sh

avatar
jamied_uk
Admin

Posts : 2320
Join date : 2010-05-09
Age : 35
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Using Sed bash Script On Linux To Generate Morse Code Without Sound

Post by jamied_uk on 15th July 2016, 02:27

avatar
jamied_uk
Admin

Posts : 2320
Join date : 2010-05-09
Age : 35
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Using Sed bash Script On Linux To Generate Morse Code Without Sound

Post by jamied_uk on 15th July 2016, 02:29

More


Code:
For every character in string:
   If character is '.':
     play "shortBeep"
   else if character is '-'
     play "shortBeep"
     play "shortBeep" # or play "longBeep"
   else
     play "noBeep" # or wait


https://unix.stackexchange.com/questions/273318/how-can-convert-characters-into-characters-thatll-produce-beep-noises/273325
avatar
jamied_uk
Admin

Posts : 2320
Join date : 2010-05-09
Age : 35
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Using Sed bash Script On Linux To Generate Morse Code Without Sound

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum