1
$ ls cn*
cn blah blah.txt
$ ls cn\ *
ls: cannot access 'cn *': No such file or directory
$ ls cn*|hexdump -C
00000000  63 6e e2 80 85 62 6c 61  68 c2 a0 62 6c 61 68 2e  |cn...blah..blah.|
00000010  74 78 74 0a                                       |txt.|
$ mv cn blah blah.txt 'cn blah blah.txt'
mv: 'cn blah blah.txt' and 'cn blah blah.txt' are the same file

Note: 0xe28085 is the UTF-8 encoding for U+2005(FOUR-PER-EM SPACE) and 0xC2A0 is the UTF-8 encoding for U+A0(NO-BREAK SPACE), and I copy pasted the first argument to mv and that is why 's are not needed around the file name, because there are no normal spaces(U+20) in the file name.

How do I rename the file so that I can type the file's name with a regular space(i.e. U+20)?

1 Answer 1

0

With zsh:

autoload zmv
zmv '*' $'${f//[\u2005\ua0]/ }'

U+2005 is usually classified as blank or space, so you can also do:

zmv '*' '${f//[[:blank:]]/ }'

Or:

zmv '*' '${f//[[:space:]]/ }'

To replace any character classified as blank or space with a U+0020 space (in the names of non-hidden files in the current working directory).

U+00A0 more rarely so as on several systems including GNU ones it's not classified as such on the ground that it is not to be used as separator/delimiter.

1
  • I ended up just rsyncing to a computer with a GUI and changing it with the GUI, and rsyncing it back. Commented Dec 3, 2023 at 22:04

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.