You are not logged in.
As the title says, I'm working on a zenity script to store a fair chunk of sample sed commands to remind myself what I can do with it. Everything seems to work fine except for the l33t to english garbler.
When that is run, it gives me this:
sed: -e expression #1, char 9: unterminated `s' command
sed: -e expression #1, char 7: unknown option to `s'
sed: -e expression #1, char 10: unterminated `s' command
sed: -e expression #1, char 5: unterminated `s' command
sed: -e expression #1, char 8: unterminated `s' command
http://pastebin.org/193208 <-- has whole script and highlighted line causing trouble <-- not updated, but I have it solved on the local copy. I'll make sure to update this when I get done cleaning up the code
[^edit: escaped characters pointed out]
But if I execute this (same trouble command, but not inside the script) [fixed typo now]:
sed s/'\/-\\'/A/g <yourfile that has /-\ for a in it>
or
echo "/-\\" | sed s/'\/-\\'/A/g
^It turns the /-\ back into an A...so...I honestly don't know what the shell is doing to interpret the same command differently.
Last edited by ShadowKyogre (2010-05-02 18:34:30)
For every problem, there is a solution that is:
Clean
Simple and most of all...wrong!
Github page
Offline
Your quoting is wrong.
[git] | [AURpkgs] | [arch-games]
Offline
The quoting is indeed a mess! But the error is from lack of escaping, and no amount of quoting will fix that.
EDIT
Although in the script you have: sed s/'\/-\\'/A/g, which is different from what you posted above.
There is an error in:
sed s/'[_-'/G/g
sed s/'[]'/O/g
sed s/'\/'/ V/g
sed s/'\|/'/W/g
So unescaped []/. And probably some more from special regex characters.
Last edited by Procyon (2010-04-29 23:03:46)
Offline
Your quoting is wrong.
The quoting is indeed a mess! But the error is from lack of escaping, and no amount of quoting will fix that.
EDIT
Although in the script you have: sed s/'\/-\\'/A/g, which is different from what you posted above.There is an error in:
sed s/'[_-'/G/g
sed s/'[]'/O/g
sed s/'\/'/ V/g
sed s/'\|/'/W/gSo unescaped []/. And probably some more from special regex characters.
*looks back at the script and my post* Whoooooooooah...that is a huge mistake o_o. *hurries to escape the regex characters in the l33t*
I'll go fix the typo in my post and I went around and escaped the ones you showed. Now only this pops up.
sed: -e expression #1, char 7: unterminated `s' command
For every problem, there is a solution that is:
Clean
Simple and most of all...wrong!
Github page
Offline
Well, without seeing your updated script I can't say for sure what's still messed up, but here's another tip: you don't need to spawn 26 instances of sed to do this.
You can replace:
sed s/'\/-\\'/A/g "$txt" | \
sed s/'|3'/B/g | \
sed s/'('/C/g | \
sed s/'|)'/D/g | \
sed s/'\&'/E/g | \
sed s/'|='/F/g | \
...
sed s/'>_'/Z/g > /tmp/lookup2.txt
With this:
sed -e s/'\/-\\'/A/g \
-e s/'|3'/B/g \
-e s/'('/C/g \
-e s/'|)'/D/g \
-e s/'\&'/E/g \
-e s/'|='/F/g \
...
-e s/'>_'/Z/g "$txt" > /tmp/lookup2.txt
Also tip: if one regex is giving you that error, then remove them one-by-one until the error goes away; then you know which one is giving you the problems.
Offline
or
sed 's/\/-\\/A/g;s/|3/B/g;s/(/C/g; ...
even, sed commands can be chained with a semicolon, also I always quote the whole script (out of habit)..
I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.
Offline
If the pattern contains "/" you can change the delimiter char to something (anything else, I think) else, eg %
sed 's%/-\\%A%g'
See info sed for details: The "s" Command.
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
If the pattern contains "/" you can change the delimiter char to something (anything else, I think) else, eg %
sed 's%/-\\%A%g'
See info sed for details: The "s" Command.
Hey, it works now! Wonder how come I didn't catch that when I was reading info sed
or
sed 's/\/-\\/A/g;s/|3/B/g;s/(/C/g; ...
even, sed commands can be chained with a semicolon, also I always quote the whole script (out of habit)..
Okay, going back to the script and cleaning up the code.
For every problem, there is a solution that is:
Clean
Simple and most of all...wrong!
Github page
Offline