bashスクリプトでディレクトリのフルパスを保存する方法は?

bashスクリプトでディレクトリのフルパスを保存する方法は?

ユーザーが「./」または「/~」を入力しても、スクリプトからフルパスディレクターを取得したいと思います。

#!/bin/bash
echo "Enter the directory"
read DIRECTORY #how to store the full-path instead of something like ./
echo "$DIRECTORY"

ベストアンサー1

使用実際のパス:

echo "$(realpath $DIRECTORY)"

おすすめ記事