I'm trying to write a simple script to take a previous command that was (accidentally) written in a non-English layout, convert everything into correct symbols and run it. I'm using Bash 4.3.11.
My current code looks like this (I'm not a programmer, just trying to learn this for general usability):
echo !! | sed -e "y/first-set-of-symbols/second-set-of-symbols/" | bash
The problem is, when I run the script from a file, I get this: "bash: line 1: !!: command not found", but when I just copy paste the whole command, it does what it's expected to do; if I change the echo part to something like "echo test-command" in the script file, that works when I run the script, too.
Could someone please help me understand why !! isn't working from a script here? Is it supposed to?
I am also open to any suggestions on how to do what I'm trying to do in a better / more efficient / more elegant way.
(I'm not using tr, because, apparently, it doesn't work with Unicode, or so they say—at least it doesn't work for me at all.)