Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://comet.sai.msu.ru/UNIXhelp/scrpt/scrpt2.4.1.2.html
Дата изменения: Fri Jan 17 12:43:19 1997 Дата индексирования: Tue Oct 2 02:04:03 2012 Кодировка: Поисковые слова: п п п п п п п п п п п п п п п |
To carry out a conditional action:
if who | grep -s keith > /dev/null then echo keith is logged in else echo keith not available fi
This lists who is currently logged on to the sytem and pipes the output through grep to search for the username keith.
The -s option causes grep to work silently and any error messages are directed to the file /dev/null instead of the standard output.
If the command is succesful i.e. the username keith is found in the list of users currently logged in then the message
keith is logged on
is displayed, otherwise the second message is displayed.