LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Eliminate a special character (https://www.linuxquestions.org/questions/programming-9/eliminate-a-special-character-4175546291/)

Aomine Daiki 06-24-2015 05:39 AM

Eliminate a special character
 
I tried to eliminate the double character == with sed:
Code:

sed -e 's/[=\]//g;s/ / /g'
but it also eliminates the character =.
I want to know how I can change it to remove only ==

pan64 06-24-2015 05:42 AM

what about:
s/==//g;

Aomine Daiki 06-24-2015 05:54 AM

i try this but it dosen't work

pan64 06-24-2015 06:00 AM

?
would be nice to see an example or detailed description. a simple "does not work" does not work.

Aomine Daiki 06-24-2015 06:14 AM

this is an example:

Quote:

Your name is: ZERBVTEX== and you have your money= TGEYM==
as you see the name and amount are coded and I want to remove the double == without touching the operator =

NevemTeve 06-24-2015 06:18 AM

Then please try what was suggested
Code:

$ sed ' s/==//g;'
(in)  Your name is: ZERBVTEX== and you have your money= TGEYM==
(out) Your name is: ZERBVTEX and you have your money= TGEYM


pan64 06-24-2015 06:18 AM

and what is the problem with s/==//g ?

rtmistler 06-24-2015 07:03 AM

Quote:

Originally Posted by pan64 (Post 5382193)
what about:
s/==//g;

This is entirely correct.

@OP you need to be more descriptive, we're not mind readers and we can offer a solution. Odds are this solution is not always a "one of" and as a result there are a variety of possible test cases where you'd need to alter different patterns. The issue there are that you need to describe the total conditions of your problem. Otherwise just saying "it didn't work" is a waste of time, because pan64's recommendation does work for your test string.

danielbmartin 06-24-2015 07:19 AM

Quote:

Originally Posted by Aomine Daiki (Post 5382191)
I tried to eliminate the double character == ...

Saying "it doesn't work" isn't especially informative. What happened? Did the computer crash? Was the input file destroyed? Was the output file identical to the input file? Was the output file created but contained no lines? Was the output file not created at all? Something else?

Perhaps there is an ambiguity in the problem statement. One person might think you want to change abc==def to abcdef and another person might think you want to change abc==def to abc=def.

Did you consider using tr -s "=" ?

Daniel B. Martin


All times are GMT -5. The time now is 05:29 AM.