Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
194 views
in Technique[技术] by (71.8m points)

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

find . -type f -print

prints out

./file1
./file2
./file3

Any way to make it print

file1
file2
file3

?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

find -type f -printf '%P
'

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...