LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-24-2015, 05:39 AM   #1
Aomine Daiki
LQ Newbie
 
Registered: Jun 2015
Location: Tunisia
Posts: 10

Rep: Reputation: Disabled
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 ==
 
Old 06-24-2015, 05:42 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
what about:
s/==//g;
 
Old 06-24-2015, 05:54 AM   #3
Aomine Daiki
LQ Newbie
 
Registered: Jun 2015
Location: Tunisia
Posts: 10

Original Poster
Rep: Reputation: Disabled
i try this but it dosen't work
 
Old 06-24-2015, 06:00 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
?
would be nice to see an example or detailed description. a simple "does not work" does not work.
 
1 members found this post helpful.
Old 06-24-2015, 06:14 AM   #5
Aomine Daiki
LQ Newbie
 
Registered: Jun 2015
Location: Tunisia
Posts: 10

Original Poster
Rep: Reputation: Disabled
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 =
 
Old 06-24-2015, 06:18 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,871
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
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
 
Old 06-24-2015, 06:18 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
and what is the problem with s/==//g ?
 
Old 06-24-2015, 07:03 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by pan64 View Post
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.
 
Old 06-24-2015, 07:19 AM   #9
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,881

Rep: Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660
Quote:
Originally Posted by Aomine Daiki View Post
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
block special and character special files s_shenbaga Linux - Newbie 4 06-23-2015 02:16 AM
sed command to replace special character in special line rubylu Linux - Newbie 3 04-09-2015 01:45 PM
Find and Replace character/special character from the file MyRelam Red Hat 8 05-21-2012 12:52 AM
i need help with a special character Hone101 Linux - Newbie 1 05-03-2003 07:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration