×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Replace accent character "é" with "e"

Replace accent character "é" with "e"

Replace accent character "é" with "e"

(OP)
hi,

I need to replace accent character "é" with "e" (I know this is not correct replacement) in my file after converting it from utf-8 to ascii.
Any help is appreciated, thanks in advance.

Command used for conversion: $iconv -c -f utf-8 -t ascii < file1.txt > file2.txt

Cheers,
BauV

RE: Replace accent character "é" with "e"

Hi

Try this, worked for my test text :

CODE

iconv -f utf-8 -t ascii//translit < file1.txt > file2.txt 

Feherke.
feherke.github.io

RE: Replace accent character "é" with "e"

(OP)
Thanks Fuherke, for the help.
I did try this already, shown with Error: tomap cannot be specified with fromcode.
Any further help is appreciated.

Cheers,
BauV

RE: Replace accent character "é" with "e"

Try unaccent:

CODE

$ echo 'xáéíy' | unaccent utf-8
xaeiy 

RE: Replace accent character "é" with "e"

Try sed:

CODE

$ echo 'xáéíy' | sed 'y/áéí/aei/'
xaeiy 

RE: Replace accent character "é" with "e"

(OP)
Thanks mikrom.
Both are showing errors, as below -
1) $ echo 'xáéíy' | unaccent utf-8 ---error: "ksh: unaccent: not found"
2) $ echo 'xáéíy' | sed 'y/áéí/aei/' ---error: sed: command garbled: y/áéí/aei/

I tried below command:
echo 'xá sdfdsédsfjdks íy' | sed -e 's/é/e/g' ---worked fine, result: "xá sdfdsedsfjdks íy"
sed -e 's/é/e/g' file1.txt > file1.res --- no luck
or
sed -e 's/é/e/g' < file1.txt > file1.res --- no luck

Any further suggestion plzz.

Cheers,
BauV

RE: Replace accent character "é" with "e"

(OP)
hi,

$file file1.txt --- says, English text or ASCII text
Does this matter?

Cheers,
BauV

RE: Replace accent character "é" with "e"

Quote:


ksh: unaccent: not found
Before I used it I had to install it on my Linux machine

CODE

sudo apt install unaccent 

RE: Replace accent character "é" with "e"

(OP)
Unfortunately I do not have required access to install unaccent.
Cheers,
BauV.

RE: Replace accent character "é" with "e"

Quote (BauV)


$file file1.txt --- says, English text or ASCII text
Does this matter?
Yes, it does matter. How it could be english ASCII containing accents áéí? Such characters are not in english ASCII encoding.
My file is in utf-8 and everything works.

CODE

$ echo 'xáéíy' > file1.txt
$ file -i file1.txt 
file1.txt: text/plain; charset=utf-8
$ sed 'y/áéí/aei/' file1.txt 
xaeiy
$ sed 'y/áéí/aei/' file1.txt > file2.txt
$ cat file1.txt file2.txt 
xáéíy
xaeiy
$ file -i file*.txt 
file1.txt: text/plain; charset=utf-8
file2.txt: text/plain; charset=us-ascii 

.. and what is your operating system ?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close