0

I want to find all html files and only show the file names, not the full file path, what I tried:

find /home/irakli/Desktop/irakli_linux -print | grep -i '.*[.]html'

Results:

/home/irakli/Desktop/irakli_linux/htmll/10.html
/home/irakli/Desktop/irakli_linux/htmll/11.html
/home/irakli/Desktop/irakli_linux/htmll/12.html
/home/irakli/Desktop/irakli_linux/htmll/13.html
/home/irakli/Desktop/irakli_linux/htmll/14.html
/home/irakli/Desktop/irakli_linux/htmll/15.html

I only want 1.html 2.html ...

Ravexina
  • 55,668
  • 25
  • 164
  • 183
Irakli
  • 103
  • 1
  • 1
  • 2

1 Answers1

6

There is no need to use grep, find can do exactly what you seek.

Use:

find  -iname "*.html" -printf "%f\n"

It will look for all html files and only prints out their name.

If you want all names at the same line:

find  -iname "*.html" -printf "%f "
Ravexina
  • 55,668
  • 25
  • 164
  • 183