Which: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Line 27: Line 27:
==Teised Unixi-laadsed operatsioonisüsteemid==
==Teised Unixi-laadsed operatsioonisüsteemid==


which [optsioonid] argument
[4] http://unixhelp.ed.ac.uk/CGI/man-cgi?which
 
which [optsioonid] [--] argument
 
      --all, -a
  Print all matching executables in PATH, not just the first.
 
      --read-alias, -i
  Read aliases from stdin, reporting matching ones on stdout. This is
  useful in combination with using an alias for which itself. For
  example
  alias which=?alias | which -i?.
 
      --skip-alias
  Ignore option `--read-alias?, if any. This is useful to explicity
  search for normal binaries, while using the `--read-alias? option
  in an alias or function for which.
 
      --read-functions
  Read shell function definitions from stdin, reporting matching ones
  on stdout. This is useful in combination with using a shell func-
  tion for which itself.  For example:
  which() { declare -f | which --read-functions $@ }
  export -f which
 
      --skip-functions
  Ignore option `--read-functions?, if any. This is useful to explic-
  ity search for normal binaries, while using the `--read-functions?
  option in an alias or function for which.
 
      --skip-dot
  Skip directories in PATH that start with a dot.
 
      --skip-tilde
  Skip directories in PATH that start with a tilde and executables
  which reside in the HOME directory.
 
      --show-dot
  If a directory in PATH starts with a dot and a matching executable
  was found for that path, then print "./programname" rather than the
  full path.
 
      --show-tilde
  Output a tilde when a directory matches the HOME directory. This
  option is ignored when which is invoked as root.
 
      --tty-only
  Stop processing options on the right if not on tty.
 
      --version,-v,-V
  Print version information on standard output then exit success-
  fully.
 
      --help
  Print usage information on standard output then exit successfully.


=Näited=
=Näited=

Revision as of 18:09, 26 December 2014

Autor

Sven Rekkaro AK21
Sügis 2014

Sissejuhatus

"which" on lihtne käsk, mis võimaldab leida käsu või skripti käivitusfaili täispika tee keskkonnamuutujas $PATH kirjeldatud süsteemi- ja/või kasutaja kaustadest. Kui kasutaja sisestab Linuxi käsureale käsu, siis kontrollib Linuxi kest (shell) $PATH keskkonnamuutujas kirjeldatud kaustades käsule vastava käivitusfaili olemasolu. Kui sobivat käivitusfaili ei leita, siis kuvatakse veateade "command not found," käivitusfaili olemasolu korral see käivitatakse. Analoogselt Linuxi kestale toimib ka käsklus "which," mis tagastab sisestatud käsu täispika tee, kui käivitusfail leitakse või tagastab veateate kui käsule on lisatud mitte-eksisteeriv optsioon. Programm ei kontrolli $PATH muutujas kirjeldatud kaustades asuvaid Symbolic linke. Programmil on kolm tagastusväärtust:

  • 0 - argumendile vastav käivitusfail leiti
  • 1 - argumendile vastavat käivitusfaili ei leitud
  • 2 - käsk sisestati koos vigase optsiooniga
[1] (URL: http://linux.about.com/library/cmd/blcmdl1_which.htm) [2] (http://manpages.debian.org/cgi-bin/man.cgi?query=which&apropos=0&sektion=0&manpath=Debian+7.0+wheezy&format=html&locale=en)

Käsu süntaks

Käsk "which" süntaks erineb mõningal määral, olenevalt kasutusel olevast Linux või BSD distributsioonist. Vähemate võimalustega on käsklus Debianil põhinevatel Linuxitel [3] (http://manpages.debian.org/cgi-bin/man.cgi?query=which&apropos=0&sektion=0&manpath=Debian+7.0+wheezy&format=html&locale=en). Keerukam on käsu süntaks teistel Unixil põhinevatel operatsioonisüsteemidel, näiteks Gentoo 2.6.23-gentoo-r8. [4] (http://unixhelp.ed.ac.uk/CGI/man-cgi?which). Käsk ei vaja toimimiseks juurkasutaja õiguseid.

Süntaks Debianil põhinevatel Linuxitel

[3] http://manpages.debian.org/cgi-bin/man.cgi?query=which&apropos=0&sektion=0&manpath=Debian+7.0+wheezy&format=html&locale=en

which [optsioonid] argument

Optsioonid:

-a prindib välja kõikide argumentide kõik leitud täispikad teed. Ilma võtmeta "-a" prinditakse ainult esimene leitud väärtus

argument- programmi, skripti või käsu nimetus. Argumente võib sisestada mitu.

Teised Unixi-laadsed operatsioonisüsteemid

[4] http://unixhelp.ed.ac.uk/CGI/man-cgi?which

which [optsioonid] [--] argument

      --all, -a

Print all matching executables in PATH, not just the first.

      --read-alias, -i

Read aliases from stdin, reporting matching ones on stdout. This is useful in combination with using an alias for which itself. For example alias which=?alias | which -i?.

      --skip-alias

Ignore option `--read-alias?, if any. This is useful to explicity search for normal binaries, while using the `--read-alias? option in an alias or function for which.

      --read-functions

Read shell function definitions from stdin, reporting matching ones on stdout. This is useful in combination with using a shell func- tion for which itself. For example: which() { declare -f | which --read-functions $@ } export -f which

      --skip-functions

Ignore option `--read-functions?, if any. This is useful to explic- ity search for normal binaries, while using the `--read-functions? option in an alias or function for which.

      --skip-dot

Skip directories in PATH that start with a dot.

      --skip-tilde

Skip directories in PATH that start with a tilde and executables which reside in the HOME directory.

      --show-dot

If a directory in PATH starts with a dot and a matching executable was found for that path, then print "./programname" rather than the full path.

      --show-tilde

Output a tilde when a directory matches the HOME directory. This option is ignored when which is invoked as root.

      --tty-only

Stop processing options on the right if not on tty.

      --version,-v,-V

Print version information on standard output then exit success- fully.

      --help

Print usage information on standard output then exit successfully.

Näited

Kokkuvõte

Kasutatud kirjandus