How to strip leading "./" in unix "find"?

breadjesus picture breadjesus · Apr 8, 2010 · Viewed 57k times · Source
find . -type f -print

prints out

./file1
./file2
./file3

Any way to make it print

file1
file2
file3

?

Answer

Ilia K. picture Ilia K. · Apr 8, 2010

Find only regular files under current directory, and print them without "./" prefix:

find -type f -printf '%P\n'

From man find, description of -printf format:

%P     File's name with the name of the command line argument under which it was found removed.