Skip to content

Instantly share code, notes, and snippets.

View i97506051502's full-sized avatar

Go Sato i97506051502

View GitHub Profile
@i97506051502
i97506051502 / listing_all_file_extensions.sh
Created June 4, 2017 22:50
listing all file extensions under directory that is assigned by first argument.
#!/bin/bash
set -ue
echo -n '' > /tmp/tmp.extensions.list
if [[ ${#} -ne 1 ]]; then
echo 'Usage:'
echo '$ bash listing_all_file_extensions.sh /path/to/directory'
else
@i97506051502
i97506051502 / wait_by_read_with_while_loop.sh
Created February 15, 2017 07:39
wait user input by using while loop and read command in while loop sample.
#!/bin/bash
# wait_by_read_with_while_loop.txt
# one
# two
# three
# four
# five
set -ue
@i97506051502
i97506051502 / study_getopt.sh
Last active January 20, 2017 10:33
いまいちよく分かっていない getopt に関するメモ.環境変数 GETOPT_COMPATIBLE がセットされている場合どんな動きになるのか? メリット・デメリットは? などなど.書きかけ
#!/bin/bash
# 下記,よくできた bash マニュアルだと思っていたら,JP1/Advanced Shell というもののマニュアルだった... bash のマニュアルを確認していないので以下はデタラメかもです.
#
# 参考
#
# getoptコマンド(コマンドラインのオプションを解析する) : JP1/Advanced Shell http://itdoc.hitachi.co.jp/manuals/3021/3021313330/JPAS0337.HTM
# 形式1
#!/bin/sh
#
# CACHE CLUSTER ID
#
PRI_CACHE_CLUSTER_ID=ec-test-pri
REP_CACHE_CLUSTER_ID=ec-test-rep
#
# REPLICATION GROUP ID
#!/bin/sh
#
# CACHE CLUSTER ID
#
PRI_CACHE_CLUSTER_ID=ec-test-pri
REP_CACHE_CLUSTER_ID=ec-test-rep
#
# REPLICATION GROUP ID
@i97506051502
i97506051502 / stop_instances.sh
Last active August 29, 2015 13:57
stop_instances.sh は,引数に渡したサーバーリスト内の EC2 インスタンスを「順番に」停止します。サーバーリストには Name タグの Value を列挙します。
#!/bin/sh
# Check number of variables.
if [ $# != 1 ]
then
echo 'Usage:'
echo './start_instances.sh servers.list'
exit 255
fi
@i97506051502
i97506051502 / start_instances.sh
Last active August 29, 2015 13:57
start_instances.sh は,引数に渡したサーバーリスト内の EC2 インスタンスを「順番に」起動します。サーバーリストには Name タグの Value を列挙します。
#!/bin/sh
# Check number of variables.
if [ $# != 1 ]
then
echo 'Usage:'
echo './start_instances.sh servers.list'
exit 255
fi
@i97506051502
i97506051502 / install_redis.sh
Created March 19, 2014 05:47
install redis 2.8 to Amazon Linux
#!/bin/sh
sudo yum install -y gcc
wget http://download.redis.io/releases/redis-2.8.6.tar.gz
tar xzf redis-2.8.6.tar.gz
cd redis-2.8.6
make
sudo cp ./src/redis-server /usr/local/bin/
sudo cp ./src/redis-cli /usr/local/bin/
@i97506051502
i97506051502 / backup_redis.sh
Last active August 29, 2015 13:56
Redis バックアップ用シェルスクリプト
#!/bin/sh
#
# Variables
#
MAIL_ADDRESS="ok@example.com"
MAIL_SUBJECT='Redis Backup ends with No Error.'
ALERT_MAIL_ADDRESS="ng@example.com"
ALERT_MAIL_SUBJECT='Redis Backup ends with Some Error!!'
@i97506051502
i97506051502 / backup_mysql.sh
Created March 4, 2014 02:34
MySQL バックアップ用シェルスクリプト
#!/bin/sh
#
# ----------------------------------------------------------------------
# Variables
# ----------------------------------------------------------------------
#
#
# Retention Period of mysqldump files.