Que comando

De openSUSE, la enciclopedia libre.


Tabla de contenidos

Situacion

El comando que has entrado en el commandline no concuerda con el documentado en el comando principal. Tienes que averiguar que comando se esta usando.


Procedimiento

Por ejemplo en la linea de comando entras:

$ time -o time.out ls
bash: -o: command not found

Pero la man page muestra un -o option. Que comando se estar corriendo ? Algunos comandos pueden ayudarte.

Comando: type

El bash builtin type es el indicado. Incluye alias y builtins cuando busca sus objetivos.

$ type time
time is a shell keyword
$ type -a time
time is a shell keyword
time is /usr/bin/time

Usa el help builtin para tener mas informacion en shell keywords.

$ help time
time: time [-p] PIPELINE
    Execute PIPELINE and print a summary of the real time, user CPU time,
   and system CPU time spent executing PIPELINE when it terminates.
   The return status is the return status of PIPELINE.  The `-p' option
   prints the timing summary in a slightly different format.  This uses
   the value of the TIMEFORMAT variable as the output format.
times: times
    Print the accumulated user and system times for processes run from
   the shell.

Veras que este time no incluye el -o option. Entonces para usar el man document version, tendras que entrar todo el camino a el.

$ /usr/bin/time -o time.out ls

Comando: which

The which command te mostrara donde encuentra el comando en el PATH. La -a option es de una importacia particular, ya que encontrara todas las instancias que encuentra en el PATH, no solo la primera. Sin embargo, no sabe sobre shell alias or builtins.

$ which time
/usr/bin/time

Nota tambien que en la instalacion normal 10.2, which is aliado en /etc/bash.bashrc to be a shell function and not the one found in /usr/bin:

$ type -a which
which is aliased to `_which'
which is /usr/bin/which
$ type -a _which
_which is a function
_which () 
{ 
   local file=$(type -p ${1+"$@"} 2>/dev/null);
   if test -n "$file" -a -x "$file"; then
       echo "$file";
       return 0;
   fi;
   hash -r;
   type -P ${1+"$@"}
}

Links

Daemon Dancing in the Dark blog - Does anybody really know what time it is?