Nota sobre la diferencia entre who
y whoami
.
El comando who
siempre mostrará la cuenta que utilizó para iniciar sesión (la información de usuario real ).
El comando whoami
mostrará su usuario efectivo.
Por ejemplo, si inicia sesión como "blammy", los comandos who
y whoami
mostrarán algo como esto:
> who
blammy pts/0 2011-04-23 13:43 (123.23.123.123)
> whoami
blammy
Esto indica que el usuario "blammy" inició sesión el 23 de abril de 2011 a las 13 :43 desde la IP "123.23.123.123".
Si luego ejecuta su - kapow
, cambias tu usuario efectivo para que sea "kapow".
Ahora, los comandos who
y whoami
mostrarán algo como esto:
> who
blammy pts/0 2011-04-23 13:43 (123.23.123.123)
> whoami
kapow
Tenga en cuenta que la información who
permanece igual, pero la información whoami
cambia según el su.
Ваша переменная видна только в вашей функции. Это работает, если вы определяете переменную в основной области видимости и присваиваете значения в функции:
#/bin/bash
#IOEngine="psync"
#TestType="read"
IOEngine="libaio"
TestType="randread"
declare -A associative_vars
vars_ioengine_defaults() {
RunTime="0"
UDCNAme="stage"
if [[ "$IOEnginge" == "psync" ]] && [[ "$TestType" == "read" ]]; then
associative_vars=([DFLT_QueueDepth]="0" [DFLT_DatasetSize]="3G" [DFLT_BlockSize]="2,4,8,16,32,64,128,256,512,1024" [DFLT_Threads]="1,2,4,8,16,32,64,128,256" [DFLT_FileSize]="3M")
elif [[ "$IOEngine" == "psync" ]] && [[ "$TestType" == "randread" ]]; then
associative_vars=([DFLT_QueueDepth]="0" [DFLT_DatasetSize]="1G" [DFLT_BlockSize]="8,16,32" [DFLT_Threads]="16,32,64,128,256" [DFLT_FileSize]="32k")
elif [[ "$IOEngine" == "libaio" ]] && [[ "$TestType" == "read" ]]; then
associative_vars=([DFLT_QueueDepth]="16" [DFLT_DatasetSize]="3G" [DFLT_BlockSize]="2,4,8,16,32,64,128,256,512,1024" [DFLT_Threads]="1,2,4,8,16,32,64,128,256" [DFLT_FileSize]="3M")
elif [[ "$IOEngine" == "libaio" ]] && [[ "$TestType" == "randread" ]]; then
associative_vars=([DFLT_QueueDepth]="16" [DFLT_DatasetSize]="1G" [DFLT_BlockSize]="8,16,32" [DFLT_Threads]="16,32,64,128,256" [DFLT_FileSize]="32k")
else
echo " Neither IOEngine nor TestType variables matched to required values"
fi
}
vars_ioengine_defaults
echo fio_gen ${associative_vars[DFLT_QueueDepth]} ${associative_vars[DFLT_DatasetSize]}