Skip to content

Instantly share code, notes, and snippets.

@okinjp
Last active October 30, 2023 08:48
Show Gist options
  • Save okinjp/b58589c9f987fae11eb5a053b14929cf to your computer and use it in GitHub Desktop.
Save okinjp/b58589c9f987fae11eb5a053b14929cf to your computer and use it in GitHub Desktop.
簡易に絶対パスを返すスクリプト
#!/usr/bin/env bash
# 第一引数がパスで第二引数以降は単純に引き渡せればいい場合は$1の代わりに$@も可
PATHTO = $1
if [[ "$PATHTO" = "/"* ]] || [[ "$PATHTO" = "~"* ]];then
PATHPREFIX=""
else
PATHPREFIX="$(pwd)/"
fi
echo "$PATHPREFIX$PATHTO"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment