Search code examples
fileunixcreation

Rename a file in unix to include $ sign (ie a java class file)


I have a java class file that is causing problems because of the length of the name:

GroundTransportationProductType$GroundTransportationOptions$GroundTransportationProductOption$GroundTransportationOptionProviderLinks$ProviderLinks.class

I have managed to get the file on the unix box (Solaris) by under a shortend file name. my.class

How can I rename my.class to the correct class name above?

Using mv and cp normally (ie not doing something for the dollar signs) does not work. I have googled and searched extensively but cannot find anything on how to create a file with a dollar name in it on unix.

Thanks,

Kenny


Solution

  • $ has a special meaning in shells, so you need to escape it somehow. The best option would be to use single quotes around your filenames. A \ in front of the '$' sign would also work.

    mv my.class 'Long$File$Name.class'
    

    or

    mv my.class Long\$File\$Name.class