The OpenNET Project / Index page

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

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

Example of using the case statement

To specify an action when a word matches the pattern:

   cat diary
   #!/bin/sh
   today=`date +%m/%d`	(presents the date in the format 01/31)
   case	$today  in
   07/18)	echo	"Aonoch Mhor"
   ;;
   07/21)	echo	"Ben Wyvis"
   ;;
   08/02)	echo	"Buicheille Etive Mhor"
   ;;
   08/03)	echo	"Slioch"
   ;;
   *)		echo	"Wet..low level today"
   esac
   date +%m/%d
   07/18
   diary
   Aonoch Mhor 

The value for the word $today is generated by the date command. This is then compared with various patterns so that the appropriate commands are executed.

Note the use of the pattern *, this can be used to specify default patterns as the * character is the shell wildcard character.


[Home] [Search] [Index]



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

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