2

After adding alias rm='rm -i' to my ~/.bashrc file (because, when I removed a file, it wasn't asking for confirmation), file names are surrounded with "â" signs as in the example below:

rm: cannot remove âfile1.txtâ: No such file or directory

List of aliases:

alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias rm='rm -i'
alias vi='vim'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

Note: I am ssh'ing to my CentOS machine with PuTTY from my Windows machine, so this is definitely a character encoding issue. Using Ubuntu guest in my VM, everything is fine. Smart quotes are showing as they need to.

  • Is there another alias for rm already? Can you show all of them? Do you also have completion enabled? – ott-- Jun 17 '15 at 20:01
  • 2
    Is there actually a file called file1.txt? That looks like the normal response from rm for a non-existent file when there is a character set translation issue (a terminal set up for ISO-8859-1 rather than UTF-8 for example) – steeldriver Jun 17 '15 at 20:01
  • @steeldriver, same for existing and non-existing file. – Alan Kis Jun 18 '15 at 17:50
  • @ott-- see edit. – Alan Kis Jun 18 '15 at 17:51
6

These âs are UTF-8 quotes that your current terminal is unable to display properly, being configured in ISO-8859-1 or similar.

You can have a proper display with setting a matching locale or the POSIX one:

$ rm file.txt
rm: cannot remove â  file.txtâ : No such file or directory
$ LC_ALL=en_US.UTF-8 rm file.txt
rm: cannot remove â  file.txtâ : No such file or directory
$ LC_ALL=C rm file.txt
rm: cannot remove 'file.txt' : No such file or directory

$ rm foo 2>&1 | od -c
0000000   r   m   :       c   a   n   n   o   t       r   e   m   o   v
0000020   e     342 200 230   f   o   o 342 200 231   :       N   o    
0000040   s   u   c   h       f   i   l   e       o   r       d   i   r
0000060   e   c   t   o   r   y  \n
0000067
$ LC_ALL=C rm foo 2>&1 | od -c
0000000   r   m   :       c   a   n   n   o   t       r   e   m   o   v
0000020   e       '   f   o   o   '   :       N   o       s   u   c   h
0000040       f   i   l   e       o   r       d   i   r   e   c   t   o
0000060   r   y  \n
0000063
  • How did you get the first rm to generate UTF-8 quotes? I'm having trouble duplicating that. I can't tell if my locale is off, or if I've got xterm doing something right, which is wrong for getting an erroneous condition. – Bruce Ediger Jun 17 '15 at 23:09
  • GNU rm generates UTF-8 opening and closing quotes when it is running under an UTF-8 locale (see my updated answer). This is by design. There is nothing specific to configure. – jlliagre Jun 17 '15 at 23:29
  • Thanks. I'm not sure that all the steps I took to duplicate are necessary but... 1. Use PuTTY, setting "Translation" to ISO-8859-1. ssh to linux machine. 2. Unset environment variables LC_ALL, TERM, TERMINAL, XTERM_LOCAL. 3. set environment variable LAN=en_US.UTF-8. I finally got UTF-8 left- and right-single quotes, 4. Run dash shell. I got ASCII single-quote bytes for all the other combos of xterm, LC_ALL, LANG, TERM, TERMINAL, etc that I tried. I also got the a-circumflex-file1.txt-a-circumflex as the question has: no visible characters after the a-circumflex as in your example. – Bruce Ediger Jun 18 '15 at 0:06
  • @BruceEdiger My tests were done using with a Solaris installation configured to use UTF-8 and in a Solaris text console, i.e. outside any graphic environment. The Solaris console doesn't support UTF-8. – jlliagre Jun 18 '15 at 6:35
  • @jlliagre, It is possible that this is character encoding problem. Most important, I forgo to mention that I am usually ssh with Putty from my Win machine. – Alan Kis Jun 18 '15 at 17:58
0

Are you sure you did not add some wierd characters? try using vi with ':set list' to see non-human readable characters in your .bashrc.

Type just 'aliases' and see if any system aliases are there, they might indicate the correct syntax that your OS uses. Otherwise, using mostly centos and redhat, your alias syntax looks already correct to me. Therefore it seems less likely to be the actual cause of your problem.

0

If (and it's a big if) you cut-n-pasted the text exactly, and some clipboard didn't mangle it...

You have a UTF-8 character in there, 2 bytes, C3 A2, which is: U+00E2, â, c3 a2, LATIN SMALL LETTER A WITH CIRCUMFLEX, both before and after the file name.

When I issue the commands:

alias rm='rm -i'
rm spdkdkdkdlsls

I get this from bash 4.3.39:

rm: cannot remove 'spdkdkdkdlsls': No such file or directory

I have LC_ALL=en_US.UTF_8 as my only locale environment variable. But the thing to note is that rm puts single-quotes around the file name. If you google around for "smart quotes c3 a2", you'll find this article and this article that seem to explain similar problems. My guess is that your TERMINAL, LC_ALL (or other locale variable) or a cut-n-paste is getting Microsoft "Word" style "smart quotes" in there somehow.

Can you do this:

ls -l > files
hexdump -C files

The hexdump output will let you see if there's actually a "file1.txt" in the directory, and show you that there's no LATIN SMALL LETTER A WITH CIRCUMFLEX in the directory listing. That means the a-circumflex is the fault of rm. or it's unfortunate attempt to account for your chosen character set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.