Linux Shellスクリプトプログラミングのif使い方の例

469 ワード

****************************プログラムファイル名:create******************************
#!/bin/bash
if [ -e $1 ]   #  if     
then
	echo "the file is already exists!"
else 
	`touch $1`
	`chmod u+x $1`
	echo "Finish!"
fi

case "$2" in
"-g" ) `gedit $1`;;
"-v" ) `gnome-terminal -x vi $1`;;
"" )	echo "";;
* )	echo "command error!";;
esac		
実行可能ファイルを作成し、ファイル名パラメータの後に-oまたは-gを選択して選択編集ツールを開くことができる.