delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/10/23/13:12:42

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-Id: <5.1.0.14.2.20021023095859.01fdfee8@pop3.cris.com>
X-Sender: rrschulz AT pop3 DOT cris DOT com
Date: Wed, 23 Oct 2002 10:13:16 -0700
To: cygwin AT cygwin DOT com
From: Randall R Schulz <rrschulz AT cris DOT com>
Subject: Re: Is it possible to copy a file from anywhere to My
Documents with bash cp?
In-Reply-To: <3B2480653E7D2C4E8AA5699598D691C4230092@xch-se-03.se.nos.bo
eing.com>
Mime-Version: 1.0

Frank,

I don't know which Windows systems use and define which environment 
variables, but under Win2K Pro, there is a system-supplied variable 
USERPROFILE which is the name of the directory in which your "My Docuents" 
directory resides.

You should be able to see the contents of your "My Documents" directory 
with this command:

% ls -l "$USERPROFILE/My Documents"

Likewise, you can move or copy files to that directory like this:

% cp SomeFile "$USERPROFILE/My Documents"
% mv OtherFile "$USERPROFILE/My Documents"

Be sure to use the precise quoting shown here. If your "SomeFile" or 
"OtherFile" have special characters in their names, quote those arguments too.

"Special characters" includes any of these: Space, $, *, [, ], &, !, @, #, 
(, ), ;, ?, ", ' and \. Using single quotes ensures completely literal 
interpretation what's between them. Using double-quotes allows variables to 
be substituted, which is essential to the examples above. If the name 
contains a single quote or a double quote, either use the opposite kind of 
quote for the overall argument or precede that quote character with a 
backslash. To get a backslash you'll always have to use two of them (the 
first escapes the second). Since backslash is a file name separator in 
Windowsyou cannot use them in file names themselves.

Whenever possible, avoid these "special" characters in your file names.


Since Cygwin commands accept both Windows / DOS file name formats as well 
as POSIX / Unix ones, the example commands shown above will work. 
Nonetheless, you might want to learn about the "cygpath" command which does 
two primary things:

- Convert back and forth between Windows / DOS and Unix / POSIX formats 
(both for single file and directory names and for PATH-like values)
- Supply the names of various essential system directories

Use the manual page ("man cygpath") or the help output ("cygpath --help") 
to learn more.


Randall Schulz
Mountain View, CA USA


At 09:51 2002-10-23, Lane, Frank L wrote:
>How can I copy a file from a directory to My Documents on a bash command
>line?  I played with it and can't hack the syntax.
>
>Thanks,
>Frank


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019