Get filename only

$ basename /path/to/file
file

Get full path to directory

$ dirname /path/to/file
/path/to

Expand home (~)

$ realpath ~/Downloads/
/Users/paul/Downloads