How do I return only file names from the find command?

With basename:

find . -type f -exec basename {} \;


Evilsoup mentioned that what was posted doesn't work for spaced file names. So instead you could use:

find . -type f -print0 | while IFS= read -r -d '' filename; do echo ${filename##*/}; done

EDIT:

Using sed:

$ find . -type f | sed 's/.*\///'

Using the xargs command, as mentioned in the response of @nerdwaller

$ find . -type f -print0 | xargs --null -n1 basename

Tags:

Terminal

Find

Mac