Windows/Linux?????????????
???????????? ???????[ 2017/2/21 11:10:48 ] ?????????????? Linux
??????Windows???写???????????Linux???写shell??????????????????卸?????????????????????????????????????????????????????????????????胁???????路????????????????
??????????????????????????????卸??????????????校????????????????谩?
????Windowscmd.exe
??????Windows???????????cmd.exe?锟�???????????where??????????????%PATH%?锟�????????????????????睢�?纾�
????wherenotepad
????whereslmgr.vbs
?????????????????%ERRORLEVEL%?????0??????%ERRORLEVEL%??????1??
????where???????????????????????????????????????????.exe??.bat??.cmd???????????????????where???????????%PATHEXT%???谐??????????胁????
??????????????????????????????wheretest????????????%PATH%?鈥�?????????????????????where???????????????????????????????????械????????????where??????????校??????????????????????????????????
????????where??????????????????????1?????校?
????1???????????????鈥�??????????????????校???????%PATH%?????????????????
????2???????????????卸?????????????????????
????????C:Userszzzbuzz???????whereabc??
????C:Userszzzbuzzabc
????C:Userszzzbuzzabc.bat
????C:Userszzzbuzzabc.cmd
????C:Userszzzbuzzabc.exe
????C:Windowsabc
????C:Windowsabc.bat
????C:Windowsabc.cmd
????C:Windowsabc.exe
????????????????????????????????????????
?????????????????鈥�??????????????????校???????%PATH%????????????????
?????????????????卸????????????%PATHEXT%???谐???????????????????泻?????????????????????小?
??????%PATHEXT%????.COM;.EXE;.BAT;.CMD??????????abc????????械?C:Userszzzbuzzabc.exe????小?
???????????where?????????????????????锌???????????????????????????????????????where???????????????????????????????????where??????????????????????????????小???????????????????????
????Linux
??????Linux?锟�??????校?????????????????????????????????????????????????????????????????????????械??????????????????
????which
????which????????????????????????路??????????????邪????????which????????Debian?????debianutils????????????????????????????????????位???????????????????????????????????魏???????????????????????????????Cygwin?锟�????????????????which:nocmdin(/usr/local/bin:/usr/bin:/bin)????
?????????梅????锟�?
????$whichbash
????/usr/bin/bash
????$echo$?
????0
????$whichnonexistent
????$echo$?
????1
???????写?????锟�?
????CMD=cmd
????ifwhich"$CMD">/dev/null2>&1;then
????echo????$CMD????
????else
????echo????$CMD??????
????fi
?????????????????which???????????????????????
????· which??????????????????械??????????????渭?????????些???校???????????????????????????0??
????· ??些?????which?????????????which????????????????些??????????小?
????type
????type??shell???????????????????????????????????????????????????????????????????STDOUT?????????????????0?????????STDERR?写??????????????????????0?????
????????type????????????????????????????????shell?卸????alias??function??builtin????????????????????????????-P???????????????睢�?????????????-P?????卸?????POSIX????校??????????????????????????
?????????梅????锟�?
????$typebash
????bashis/usr/bin/bash
????$echo$?
????0
????$typenonexistent
????nonexistent:notfound
????$echo$?
????1
???????写?????锟�?
????CMD=cmd
????iftype"$CMD">/dev/null2>&1;then
????echo????$CMD????
????else
????echo????$CMD??????
????fi
????hash
????hash??shell??????????????????????????位??????????????????魏??????????0??????????????????STDERR??????????????????????????????0?????
?????????梅????锟�?
????$hashbash
????$echo$?
????0
????$hashnonexistent
????sh:1:hash:nonexistent:notfound
????$echo$?
????1
???????写?????锟�?
????CMD=cmd
????ifhash"$CMD"2>/dev/null;then
????echo????$CMD????
????else
????echo????$CMD??????
????fi
???????hash????????????????????????????????????????????????shell??hash??????????????位?????????????????????????????????????????械????????????????????????????????????????貌?????hash??????????????谩?
????command
????command??????shell???????????????????????????????-v??????????????????泄??????
???????????STDERR???????????????????????-v???????????STDOUT??????????????路????
??????????????????????????command????0???????????????0?????
?????????梅????锟�?
????$command-vbash
????/usr/bin/bash
????$echo$?
????0
????$command-vnonexistent
????$echo$?
????1
???????写?????锟�?
????CMD=cmd
????ifcommand-v"$CMD">/dev/null2>&1;then
????echo????$CMD????
????else
????echo????$CMD??????
????fi
????command???????POSIX???????????????????????????渭?????????写??????????????????????????????
??????

???路???
??????????????????
2023/3/23 14:23:39???写?貌??????????
2023/3/22 16:17:39????????????????????些??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???路???????路
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11