Skip to content

Instantly share code, notes, and snippets.

@nekoruri
Last active January 5, 2017 02:41
Show Gist options
  • Save nekoruri/6290799 to your computer and use it in GitHub Desktop.
Save nekoruri/6290799 to your computer and use it in GitHub Desktop.
よく使いそうなbash関数
# DEBUG付いてるときだけデバッグ出力
function debug() { ((DEBUG)) && echo "$*"; }
# タイムスタンプ付き出力
function ts() { echo $(date +'%Y/%m/%d %H:%M:%S')" $1"; }
# タイムスタンプ付きデバッグ出力
function debugts() { debug $(date +'%Y/%m/%d %H:%M:%S')" $1"; }
# ディレクトリの絶対パス
# 文字列を表示して返すので basedir=$(absdirname $0) とかやって使う。
function absdirname() { echo $(readlink -f $(dirname $1)) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment