Find the answer to your Linux question:
Results 1 to 8 of 8
I am very new to Linux and am having trouble copying a file that has both periods and spaces in the filename. I did see where you use a escape ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2005
    Location
    Maryland
    Posts
    2

    Copying Files with Spaces and special characters


    I am very new to Linux and am having trouble copying a file that has both periods and spaces in the filename. I did see where you use a escape character to show where the space or period is but it keeps erroring on me. I am trying to copy a file named P.O. Quality Clauses.doc and I am trying it this way P/.O/./ Quality/ Clauses.doc and I am doing something wrong I am sure.

  2. #2
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    Location
    London, England
    Posts
    471
    use single quotes to wrap around the entire file name like this 'P.O. Quality Clauses.doc'

  3. #3
    Just Joined!
    Join Date
    Apr 2005
    Location
    Maryland
    Posts
    2

    Thanks

    Thanks I appreciate it. That was perfect.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    Location
    London, England
    Posts
    471
    anytime, anything else you need, feel free to ask

  6. #5
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    You can also use double quotes, but shell variables will still be expanded. It will pay you to learn the subtleties of the shell's quoting mechanisms so you can work out what's happening when you get bitten by it again (and you surely will!).

  7. #6
    Linux User eugrus's Avatar
    Join Date
    Dec 2004
    Location
    Russia
    Posts
    391
    Code:
    cp "very very very long filename" "the second one"

  8. #7
    Linux Newbie
    Join Date
    Apr 2005
    Location
    Charlottesville, VA
    Posts
    175
    If you still want to use the slashes, though, the slashes need to go the other way. Also, there's no need to slash off periods.
    ---sxeraverx---
    Linux without a C Compiler is like eating Spaghetti with your mouth sewn shut. It just doesn't make sense.

  9. #8
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Quote Originally Posted by sxeraverx
    Also, there's no need to slash off periods.
    This is one of the areas of confusion between shell patterns and regular expressions. Dot in a regular expression matches any single character; you use a question mark in shell patterns. (Also * matches any number of characters in the shell, while it matches zero or more occurrences of the preceding character in a regular expression.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •