Content-type: text/html Cygwin Utilities

Cygwin Utilities

Section: Cygwin
This page is an edited version of http://cygwin.com/cygwin-ug-net/using-utils.html
Return to Main Contents
Cygwin comes with a number of command-line utilities that are used to manage the UNIX emulation portion of the Cygwin environment. While many of these reflect their UNIX counterparts, each was written specifically for Cygwin.

cygpath

Usage: cygpath [-p|--path] (-u|--unix)|(-w|--windows [-s|--short-name]) filename
       cygpath [-v|--version]
       cygpath [-W|--windir|-S|--sysdir]
  -u|--unix       print UNIX form of filename
  -w|--windows    print Windows form of filename
  -s|--short-name print Windows short form of filename
  -p|--path       filename argument is a path
  -v|--version    print program version
  -W|--windir     print Windows directory
  -S|--sysdir     print Windows system directory
  -i|--ignore     ignore missing filename argument

The cygpath program is a utility that converts Windows native filenames to Cygwin POSIX-style pathnames and back. It can be used when a Cygwin program needs to pass a file name to a native Windows program, or expects to get a file name from a native Windows program. You may use the long or short option names interchangeably, even though only the short ones are described here.

The -u and -w options indicate whether you want a conversion from Windows to UNIX (POSIX) format (-u) or a conversion from UNIX (POSIX) to Windows format (-w). You must give exactly one of these. To give neither or both is an error. Use the -s option in combination with the -w option to convert to Windows short form.

The -p option means that you want to convert a path-style string rather than a single filename. For example, the PATH environment variable is semicolon-delimited in Windows, but colon-delimited in UNIX. By giving -p you are instructing cygpath to convert between these formats.

The -i option supresses the print out of the usage message if no filename argument was given. It can be used in make file rules converting variables to a proper format that may be omitted.

Example 3-5. Example cygpath usage

#!/bin/sh
for i in `echo *.exe | sed 's/\.exe/cc/'`
do
  notepad "`cygpath -w $i`"
done

This document was created using http://cygwin.com/cygwin-ug-net/using-utils.html
Return to Main Contents