Command of the day (12 Oct) - basename

codlinuxbasename

basename - Extract filename from path

    basename /path/file : Extract file from path

    basename -a file1 file2 : Apply to multiple files

    basename file.ext ext: Removes extension ext from file name

    basename "$(readlink /proc/$$/exe)": Gives you the executable name of the current shell

    find . -type f | xargs -n1 basename: List only filenames (ignoring full paths)

 

Get your free ebook

Learn GNU/Linux one command a day

Return to Home Page