Need help to remove one Temporary file

Discussion in 'OS X Mountain Lion (10.8)' started by kingofkind, Jun 6, 2013.

  1. macrumors member

    Joined:
    May 30, 2011
    #1
    Hi all,

    I have recently been trying to learn Python scripting using LPTHW. While using terminal I came across a temporary file (~$file.xlsm) that shows up in terminal, but is not shown in Finder. running "rm ~$file.xlsm" does not work. Anyone have any suggestions?
     
  2. itickings, Jun 6, 2013
    Last edited: Jun 6, 2013

    macrumors 6502a

    itickings

    Joined:
    Apr 14, 2007
    #2
    Code:
    rm ~\$file.xlsm
    If you don't escape the $, it is going to interpret $file as a variable and replace it with the content of that variable. Compare the outputs from the following two commands:

    Code:
    echo ~\$file.xlsm
    echo ~$file.xlsm
    
     
  3. thread starter macrumors member

    Joined:
    May 30, 2011
    #3
    Thanks for the reply. the real file name also has spaces in it (I didnt name the file). When I run the rm it gives me three outputs. How do I tell the terminal to ignore the spaces?
     
  4. macrumors 604

    Joined:
    Mar 26, 2008
    Location:
    West Suburban Boston Ma
    #4
    I don't remember exactly if it works in osx, but in *NIX you could use forward slash to allow unusual characters to be input...

    ie \
     
  5. macrumors 6502a

    itickings

    Joined:
    Apr 14, 2007
    #5
    Put it in quotes, or add \ before the spaces, just like before the $.

    Code:
    rm "name with spaces"
    rm name\ with\ spaces
    When asking for help it is generally a good idea to give an example that actually matches your problem instead of rewriting it into something else.

    Backslash, right? ;)
     
  6. macrumors 604

    Joined:
    Mar 26, 2008
    Location:
    West Suburban Boston Ma
    #6
    guess I'm feeling backwards today..
     
  7. macrumors 6502a

    itickings

    Joined:
    Apr 14, 2007
    #7
    On the plus side - the backlash wasn't too bad.
     

Share This Page