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

find . -type f -print 

displays

 ./file1 ./file2 ./file3 

Any way to print

 file1 file2 file3 

?

+119
unix find strip
Apr 07 2018-10-22T00:
source share
4 answers

If they are only in the current directory

find * -type f -print

Is this what you want?

+35
Apr 07 '10 at
source share

Find only regular files in the current directory and print them without the prefix " ./ ":

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

From a human search, the description of the -printf format:

% P The name of the file with the name of the command line argument in which it was deleted.

+208
Apr 08 '10 at 0:10
source share

Use sed

 find . | sed "s|^\./||" 
+48
Apr 7 '10 at
source share

it may be shorter

 find * -type f 
+12
Apr 07 '10 at 23:45
source share



All Articles