[How To] Get only filename from full file path

Getting only the filename from the full file path complete with parent directories is just a matter of single command in Unix. Of course, there are complicated ways like using sed, awk and tr, but we can easily do this with the 'basename' command.

basename command strips directory and suffix from filenames.

[Syntax]
$ basename [full_file_path]

[Example]
$ basename /animals/mammals/humans/woman
woman

basename command - Vishal Lambe - click on the image to enlarge
Also see how to get only directory path from full filepath.