The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Поиск:  Каталог документации

Example of using an if construct

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.


[Home] [Search] [Index]



Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру