which / command substitution
- leren werken met which
Tik het commando
$ man whichWHICH(1) General Commands Manual WHICH(1) NAME which - locate a command SYNOPSIS which [-a] filename ... DESCRIPTION which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell. It does this by searching the PATH for executable files matching the names of the arguments. It does not follow symbolic links.... en probeer te begrijpen wat
whichdoet ... maar denk niet te lang na ...
om te zien watwhichecht doet tik je nu:
$ which which
schrijf het resultaat op.
- directory
/bin
gebruikwhichmet de volgende commando's
schrijf telkens het resultaat op:
lsmkdirbashping
vraag nu de inhoud van/binop metls, en interpreteer wat je ziet.
- commando's
file-whichen command-substitution
tik
$ file /bin/ping
vergelijk met
$ file $(which ping)
Als je een commando insluit in $(commandoreeks) kun je de output van dat commando gebruiken als input. Het lijkt op een pipe maar het werkt duidelijk anders. Probeer maar eens om het volgende in te tikken:
$ which ping | file
- file types in /bin
zoek van de commando's in punt 2. het filetype op metfile