Introduction to the use of the "Which" command under Linux Systems in the Windows family

Source: Internet
Author: User
Tags goto resource

Under Linux, there is a command called which, which finds the directory in the path where a command resides and displays it.

Linux under:
[adam@i ase adam]$ which LS
/bin/ls
[Adam@i ASE adam]$ which RM
/BIN/RM has a where.exe in the NT Resource Kit, which has the same effect, but resource kit is charged, where we can make a batch file to implement this function.

Use Notepad to edit a which.bat and store it in a directory in the WI T directory or in other path variables, and the contents of the batch file are as follows:

@echo off Rem check command line arguments
If {%1}=={} goto:usage
For%%i I ({{/{-) do if {%1}==%%i} goto:usage%%i
Echo. : Rem Check to see if the file exists in the current directory
For%%i I (% 1) do if exist%%~nx%i (
Echo%%~fi
Goto:eof
): Rem checks the file in path
For%%i I (% 1) do (
If exist%%~ $PATH: I (
echo%%~ $PATH: I
) Else (
Echo Error:%1 is not in the path!!!
Goto:usage
)
)
Goto:eof
: Usage
Echo.
echo WHICH Quot;filename "
Echo.
echo input file, return the full path of the file!
Echo.

Let's take a test of our program:

Microsoft Window (Versio 5.00.2195)
(C) All rights reserved 1985-1998 Microsoft Corp. C:>which WH ICH quot;filename "Input file, return the full path to the file!"
C:>which cmd.exe c:wi Tsystem32cmd.exe c:> OK, test pass!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.