Last active
September 25, 2016 05:06
-
-
Save lv7777/0c9fba158cfcb18b1b15a2f555c8b4dc to your computer and use it in GitHub Desktop.
help機能を付けるなどした
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! bin/bash | |
#backupsin.sh | |
#引数を学んだものだけが作成できる真のshellscript | |
#$x(回りに名にもなし)は展開される。""で囲んだ文字列も展開される。両者は基本的に>同じ | |
# bashもjsみたいに最初に関数を書いて定義してから実行しないとダメ。 | |
function hp { | |
#helpを表示する | |
cat <<- EOF | |
このスクリプトは周作です。ファイルパスを引数に取り、それのファイル名に.bakという | |
拡張子をつけたバックアップファイルを作成して終わる。 | |
EOF | |
exit 114514 | |
} | |
if [ $# -eq 0 ];then hp;fi | |
if [ $1 = "-h" ];then hp;fi | |
for args in "$@" ;do | |
if test -e $args.bak ;then | |
echo file${args}.bak was exist | |
continue | |
elif test ! -e $args ;then | |
echo file$args isnt exist! | |
continue | |
fi | |
cp $args ${args}.bak | |
done | |
echo "end" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment