The dirname command will give you the path of the file that you provide as parameter, up to its parent directory. If the parameter is an absolute path, the absolute containing directory will be returned, otherwise it will be the relative path.

For example, for the file /home/marios/.bash_aliases:

[email protected]:~$ dirname /home/marios/.bash_aliases 
[email protected]:~$ dirname ~/.bash_aliases 
[email protected]:~$ dirname .bash_aliases 

See also