Search code examples
bashdirectoryfilenames

fix special character in filename


Playing around with some scala I forgot to use path = path.replaceFirst("^~", System.getProperty("user.home")) e.g. directly wrote a csv file to ~/stuff/foo.csv unfortunately this resulted in:

02 22 Nov 19:59 ~

e.g. a folder with ~ in the name. How can I remove / rename that folder without messing up ~/


Solution

  • Put it in single quotes. You can move it to another name before deleting it.

    $ mv '~' foo