This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Is it possible to copy a file from anywhere to My Documents with bash cp?


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]