【背景】
折腾:
期间,需要把一些cygcheck出来的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05 $ cygcheck /usr/lib/gcc/i686-pc-cygwin/4.5.3/cc1.exe D:\tmp\tmp_dev_root\cgwin\lib\gcc\i686-pc-cygwin\4.5.3\cc1.exe D:\tmp\tmp_dev_root\cgwin\bin\cygcloog-0.dll D:\tmp\tmp_dev_root\cgwin\bin\cygwin1.dll C:\Windows\system32\KERNEL32.dll C:\Windows\system32\API-MS-Win-Core-RtlSupport-L1-1-0.dll C:\Windows\system32\ntdll.dll C:\Windows\system32\KERNELBASE.dll C:\Windows\system32\API-MS-Win-Core-ProcessThreads-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-Heap-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-Memory-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-Handle-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-Synch-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-File-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-IO-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-ThreadPool-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-LibraryLoader-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-NamedPipe-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-Misc-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-SysInfo-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-Localization-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-ProcessEnvironment-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-String-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-Debug-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-ErrorHandling-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-Fibers-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-Util-L1-1-0.dll C:\Windows\system32\API-MS-Win-Core-Profile-L1-1-0.dll C:\Windows\system32\API-MS-Win-Security-Base-L1-1-0.dll D:\tmp\tmp_dev_root\cgwin\bin\cyggmp-10.dll D:\tmp\tmp_dev_root\cgwin\bin\cygppl_c-4.dll D:\tmp\tmp_dev_root\cgwin\bin\cygppl-9.dll D:\tmp\tmp_dev_root\cgwin\bin\cyggcc_s-1.dll D:\tmp\tmp_dev_root\cgwin\bin\cygstdc++-6.dll D:\tmp\tmp_dev_root\cgwin\bin\cyggmpxx-4.dll D:\tmp\tmp_dev_root\cgwin\bin\cygpwl-5.dll D:\tmp\tmp_dev_root\cgwin\bin\cyggmp-3.dll D:\tmp\tmp_dev_root\cgwin\bin\cygiconv-2.dll D:\tmp\tmp_dev_root\cgwin\bin\cygintl-8.dll D:\tmp\tmp_dev_root\cgwin\bin\cygmpc-1.dll D:\tmp\tmp_dev_root\cgwin\bin\cygmpfr-1.dll D:\tmp\tmp_dev_root\cgwin\bin\cygmpfr-4.dll D:\tmp\tmp_dev_root\cgwin\bin\cygppl_c-2.dll D:\tmp\tmp_dev_root\cgwin\bin\cygppl-7.dll D:\tmp\tmp_dev_root\cgwin\bin\cygz.dll |
中的windows路径:
D:\tmp\tmp_dev_root\cgwin\bin C:\Windows\system32 |
转换为Cygwin的路径。
注:其实这些路径相对不复杂,自己都可以手动写出来了。
但是还是要尽量去使用cygwin中的工具,搞懂如何使用,如何转换路径。
【折腾过程】
1.自己试了试,结果没搞懂:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath --help Usage: cygpath (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]... NAME... cygpath [-c HANDLE] cygpath [-ADHOPSW] cygpath [-F ID] Convert Unix and Windows format paths, or output system path information Output type options: -d, --dos print DOS (short) form of NAMEs (C:\PROGRA~1\) -m, --mixed like --windows, but with regular slashes (C:/WINNT) -M, --mode report on mode of file (binmode or textmode) -u, --unix (default) print Unix form of NAMEs (/cygdrive/c/winnt) -w, --windows print Windows form of NAMEs (C:\WINNT) -t, --type TYPE print TYPE form: 'dos', 'mixed', 'unix', or 'windows' Path conversion options: -a, --absolute output absolute path -l, --long-name print Windows long form of NAMEs (with -w, -m only) -p, --path NAME is a PATH list (i.e., '/bin:/usr/bin') -s, --short-name print DOS (short) form of NAMEs (with -w, -m only) -C, --codepage CP print DOS, Windows, or mixed pathname in Windows codepage CP. CP can be a numeric codepage identifier, or one of the reserved words ANSI, OEM, or UTF8. If this option is missing, cygpath defaults to the character set defined by the current locale. System information: -A, --allusers use `All Users' instead of current user for -D, -O, -P -D, --desktop output `Desktop' directory and exit -H, --homeroot output `Profiles' directory (home root) and exit -O, --mydocs output `My Documents' directory and exit -P, --smprograms output Start Menu `Programs' directory and exit -S, --sysdir output system directory and exit -W, --windir output `Windows' directory and exit -F, --folder ID output special folder with numeric ID and exit Other options: -f, --file FILE read FILE for input; use - to read from STDIN -o, --option read options from FILE as well (for use with --file) -c, --close HANDLE close HANDLE (for use in captured process) -i, --ignore ignore missing argument -h, --help output usage information and exit -V, --version output version information and exit CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -u D:\tmp\tmp_dev_root\cgwin\bin\ > ^C CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -u D:\tmp\tmp_dev_root\cgwin\bin D:tmptmp_dev_rootcgwinbin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -t u D:\tmp\tmp_dev_root\cgwin\bin Usage: cygpath (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]... NAME... cygpath [-c HANDLE] cygpath [-ADHOPSW] cygpath [-F ID] Convert Unix and Windows format paths, or output system path information Output type options: -d, --dos print DOS (short) form of NAMEs (C:\PROGRA~1\) -m, --mixed like --windows, but with regular slashes (C:/WINNT) -M, --mode report on mode of file (binmode or textmode) -u, --unix (default) print Unix form of NAMEs (/cygdrive/c/winnt) -w, --windows print Windows form of NAMEs (C:\WINNT) -t, --type TYPE print TYPE form: 'dos', 'mixed', 'unix', or 'windows' Path conversion options: -a, --absolute output absolute path -l, --long-name print Windows long form of NAMEs (with -w, -m only) -p, --path NAME is a PATH list (i.e., '/bin:/usr/bin') -s, --short-name print DOS (short) form of NAMEs (with -w, -m only) -C, --codepage CP print DOS, Windows, or mixed pathname in Windows codepage CP. CP can be a numeric codepage identifier, or one of the reserved words ANSI, OEM, or UTF8. If this option is missing, cygpath defaults to the character set defined by the current locale. System information: -A, --allusers use `All Users' instead of current user for -D, -O, -P -D, --desktop output `Desktop' directory and exit -H, --homeroot output `Profiles' directory (home root) and exit -O, --mydocs output `My Documents' directory and exit -P, --smprograms output Start Menu `Programs' directory and exit -S, --sysdir output system directory and exit -W, --windir output `Windows' directory and exit -F, --folder ID output special folder with numeric ID and exit Try `cygpath --help' for more information. CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -t u D:\tmp\tmp_dev_root\cgwin\bin -a Usage: cygpath (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]... NAME... cygpath [-c HANDLE] cygpath [-ADHOPSW] cygpath [-F ID] Convert Unix and Windows format paths, or output system path information Output type options: -d, --dos print DOS (short) form of NAMEs (C:\PROGRA~1\) -m, --mixed like --windows, but with regular slashes (C:/WINNT) -M, --mode report on mode of file (binmode or textmode) -u, --unix (default) print Unix form of NAMEs (/cygdrive/c/winnt) -w, --windows print Windows form of NAMEs (C:\WINNT) -t, --type TYPE print TYPE form: 'dos', 'mixed', 'unix', or 'windows' Path conversion options: -a, --absolute output absolute path -l, --long-name print Windows long form of NAMEs (with -w, -m only) -p, --path NAME is a PATH list (i.e., '/bin:/usr/bin') -s, --short-name print DOS (short) form of NAMEs (with -w, -m only) -C, --codepage CP print DOS, Windows, or mixed pathname in Windows codepage CP. CP can be a numeric codepage identifier, or one of the reserved words ANSI, OEM, or UTF8. If this option is missing, cygpath defaults to the character set defined by the current locale. System information: -A, --allusers use `All Users' instead of current user for -D, -O, -P -D, --desktop output `Desktop' directory and exit -H, --homeroot output `Profiles' directory (home root) and exit -O, --mydocs output `My Documents' directory and exit -P, --smprograms output Start Menu `Programs' directory and exit -S, --sysdir output system directory and exit -W, --windir output `Windows' directory and exit -F, --folder ID output special folder with numeric ID and exit Try `cygpath --help' for more information. CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ |
2.最后还是自己摸索出来了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p D:\tmp\tmp_dev_root\cgwin\bin -u D:tmptmp_dev_rootcgwinbin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p D:\tmp\tmp_dev_root\cgwin\bin D:tmptmp_dev_rootcgwinbin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p D:\tmp\tmp_dev_root\cgwin\bin -a /cygdrive/d/tmptmp_dev_rootcgwinbin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p "D:\tmp\tmp_dev_root\cgwin\bin" -a /usr/bin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p /usr/bin -a /usr/bin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p /usr/bin -a -w D:\tmp\tmp_dev_root\cgwin\bin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p "/usr/bin" -a -w D:\tmp\tmp_dev_root\cgwin\bin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p "D:\tmp\tmp_dev_root\cgwin\bin" -a -u /usr/bin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p D:\\tmp\\tmp_dev_root\\cgwin\bin -a -u /cygdrive/d/tmp/tmp_dev_root/cgwinbin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p D:\\tmp\\tmp_dev_root\\cgwin\bin -u /cygdrive/d/tmp/tmp_dev_root/cgwinbin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p D:\\tmp\\tmp_dev_root\\cgwin\\bin -a -u /usr/bin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p D:\\tmp\\tmp_dev_root\\cgwin\\bin -u /usr/bin CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ |
如图:
3.另外的那个路径:
1 2 3 | CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05/output/build/host-libtool-2.2.10 $ cygpath -p "C:\Windows\system32" -a -u /cygdrive/c/Windows/system32 |
【总结】
1.将Windows路径转换为unix即Linux路径:
1 2 | $ cygpath -p "D:\tmp\tmp_dev_root\cgwin\bin" -a /usr/bin |
或:
1 2 | $ cygpath -p D:\\tmp\\tmp_dev_root\\cgwin\\bin -a -u /usr/bin |
或:
1 2 | $ cygpath -p D:\\tmp\\tmp_dev_root\\cgwin\\bin -u /usr/bin |
2.将Unix/Linux/Cygwin路径转换为Windows路径:
1 2 | $ cygpath -p /usr/bin -a -w D:\tmp\tmp_dev_root\cgwin\bin |
或:
1 2 | $ cygpath -p "/usr/bin" -a -w D:\tmp\tmp_dev_root\cgwin\bin |
参数解释:
- -p==–path:表示(给定的NAME是)path路径(而不是文件)
- -a:表示absolute,绝对路径
- -u==–unix:表示Unix,即Linux,即Cygwin下面的路径
- -w==-windows:表示windows路径
提示:
- 路径是否加括号:如果是Windows中的路径,包含了反斜杠,空格(甚至是括号)等特殊字符,最好要加括号,否则,就要用反斜杠,即:
- 要么是:"D:\tmp\tmp_dev_root\cgwin\bin"
- 要么是:D:\\tmp\\tmp_dev_root\\cgwin\\bin
转载请注明:在路上 » 【记录】Cygwin下把Windows的路径转换为Linux路径