Unable to copy a file with '$' in name in Linux

前端 未结 3 2110
遇见更好的自我
遇见更好的自我 2021-01-11 23:53

Inside of my Linux directory, I have a file named TopSample$Config.class. Whenever I try to copy this file to another location/directory, it is not allowing m

相关标签:
3条回答
  • 2021-01-12 00:03

    Or replace the offending character with the filename metacharacter of '?', meaning "any one character". Note that while this might be more convenient and requires the fewest keystrokes, be aware that a filename of TopSample?Config.class will also match TopSampleaConfig.class, TopSamplebConfig.class, TopSamplecConfig.class, etc.

    0 讨论(0)
  • 2021-01-12 00:04

    The shell will interpret $Config as a variable. And it will expand to empty string.
    You can put single quotes around to keep the literal value:

    cp 'TopSample$Config.class' /home/praveen/com/config/
    

    Another way is to escape the $(dollar sign) by using \(backslash)

    cp TopSample\$Config.class /home/praveen/com/config/
    
    0 讨论(0)
  • 2021-01-12 00:04

    Put single quotes around the filename.

    cp 'TopSample$Config.class' /home/praveen/com/config
    
    0 讨论(0)
提交回复
热议问题