Skip to content

Instantly share code, notes, and snippets.

@lv7777
Last active September 25, 2016 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lv7777/0c9fba158cfcb18b1b15a2f555c8b4dc to your computer and use it in GitHub Desktop.
Save lv7777/0c9fba158cfcb18b1b15a2f555c8b4dc to your computer and use it in GitHub Desktop.
help機能を付けるなどした
#! 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