Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9251195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:38:09+00:00 2026-06-18T10:38:09+00:00

I’m trying to copy a file using scp in bash with a colon (

  • 0

I’m trying to copy a file using scp in bash with a colon (:) character in the source filename. The obfuscated version of my command I’m using is:

scp file\:\ name.mp4 user@host:"/path/to/dest"

I get this error:

ssh: Could not resolve hostname Portal 2: Name or service not known

I know I could just rename the file and remove the :, but I’d like to know if it’s possible to escape the colon.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:38:10+00:00Added an answer on June 18, 2026 at 10:38 am

    Not quite a bash escaping problem, it’s scp treating x: as a [user@]host prefix, try:

    scp ./file:\ name.mp4 user@host:"/path/to/dest"
    

    Using relative (e.g. ./) or fully qualified paths (/path/to/source) prevents this behaviour – the presence of / before a : causes OpenSSH to stop checking for a possible host: or user@host: prefix).

    OpenSSH’s scp only special-cases filenames that start with a colon allowing those to work without problems, it has no support for escaping a : in the normal sense, and has no other notion of valid hostnames so almost any filename with a : can cause this (or equivalent IPv6 behaviour if [ ] are found before :).

    This can also affect other programs, e.g. rsync, the same workaround applies there.

    (Due to OpenSSH’s simplistic parsing of [] enclosed IPv6 addresses, you can successfully scp files containing : which start with [, or contain @[ before the : and do not contain ]: , but that’s not generally useful 😉


    (The below text was written when the original question was How do I escape a colon in bash? It applies to that situation, but not to scp as no amount of shell escaping will help there.)

    To answer the question about how to escape :, you don’t need to, but “\:” works. Places that a : is used:

    1. the null command :, no need to escape, though you can, just like \e\c\h\o foo it has no effect on the command (“no effect” is not completely true, if you escape one or more characters it will prevent an alias being matched, and you can alias :)
    2. PATH (and others, CDPATH, MAILPATH) escaping the values has no useful effect (I have been unable to run a program in my PATH from a directory containing a :, which is a little unexpected)
    3. parameter expansion ${name:-x} and more, name must be [a-zA-Z_][a-zA-Z0-9_], so no need to escape variables names, and since there’s no ambiguity, no need to escape subsequent : in the other variations of parameter expansion
    4. ? : trinary operates only on variables and numbers, no need to escape
    5. == and =~ with classes in the pattern like [[:digit:]], you can escape with \: but I’m at a loss as to how that might ever be useful…
    6. within command or function names, no need to escape, \: has no useful effect

    (Note that the null command is just :, you can have a command or function named like “:foo” and it can be invoked without escaping, in this respect it’s different to # where a command named #foo would need to be escaped.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am trying to render a haml file in a javascript response like so:
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.