Find recursively in folders, subfolders and multiple files [duplicate]












0















This question already has an answer here:




  • How to Search for Files Recursively into Subdirectories

    4 answers



  • How do you output the filename in find command while using -exec?

    7 answers




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 ...










share|improve this question









New contributor




Irakli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by Sergiy Kolodyazhnyy command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 11:26


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • @Sergiy I doubt this is a duplicate of How to Search for Files Recursively into Subdirectories. This one particularly asks how to print just the filename (without the path) while the other one asks for find in general.
    – PerlDuck
    Dec 30 '18 at 11:56












  • @PerlDuck Admittedly, the many top answers don't mention printing only filename without path, however IMHO it's a matter of reading the manual and adding proper flag to the command. I have, however, edited my own answer there to mention some of the flags find has, so hopefully that covers it. Alternatively, askubuntu.com/a/651321/295286 would probably be a more appropriate, and it pretty much same question in the title. Feel free to vote on reopening, though.
    – Sergiy Kolodyazhnyy
    Dec 30 '18 at 12:01










  • @SergiyKolodyazhnyy Congrats on command-line gold :) This seems more of a duplicate for printing basename only?
    – WinEunuuchs2Unix
    Dec 30 '18 at 14:46










  • @WinEunuuchs2Unix Hi, thanks. I've had command-line gold for about 2-3 years now. Check the list of duplicates to this post - there's two, How do you output the filename in find command while using -exec? addresses that issue.
    – Sergiy Kolodyazhnyy
    Dec 30 '18 at 22:53
















0















This question already has an answer here:




  • How to Search for Files Recursively into Subdirectories

    4 answers



  • How do you output the filename in find command while using -exec?

    7 answers




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 ...










share|improve this question









New contributor




Irakli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by Sergiy Kolodyazhnyy command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 11:26


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • @Sergiy I doubt this is a duplicate of How to Search for Files Recursively into Subdirectories. This one particularly asks how to print just the filename (without the path) while the other one asks for find in general.
    – PerlDuck
    Dec 30 '18 at 11:56












  • @PerlDuck Admittedly, the many top answers don't mention printing only filename without path, however IMHO it's a matter of reading the manual and adding proper flag to the command. I have, however, edited my own answer there to mention some of the flags find has, so hopefully that covers it. Alternatively, askubuntu.com/a/651321/295286 would probably be a more appropriate, and it pretty much same question in the title. Feel free to vote on reopening, though.
    – Sergiy Kolodyazhnyy
    Dec 30 '18 at 12:01










  • @SergiyKolodyazhnyy Congrats on command-line gold :) This seems more of a duplicate for printing basename only?
    – WinEunuuchs2Unix
    Dec 30 '18 at 14:46










  • @WinEunuuchs2Unix Hi, thanks. I've had command-line gold for about 2-3 years now. Check the list of duplicates to this post - there's two, How do you output the filename in find command while using -exec? addresses that issue.
    – Sergiy Kolodyazhnyy
    Dec 30 '18 at 22:53














0












0








0








This question already has an answer here:




  • How to Search for Files Recursively into Subdirectories

    4 answers



  • How do you output the filename in find command while using -exec?

    7 answers




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 ...










share|improve this question









New contributor




Irakli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












This question already has an answer here:




  • How to Search for Files Recursively into Subdirectories

    4 answers



  • How do you output the filename in find command while using -exec?

    7 answers




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 ...





This question already has an answer here:




  • How to Search for Files Recursively into Subdirectories

    4 answers



  • How do you output the filename in find command while using -exec?

    7 answers








command-line find






share|improve this question









New contributor




Irakli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Irakli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Dec 30 '18 at 11:13









Ravexina

31.4k1481110




31.4k1481110






New contributor




Irakli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Dec 30 '18 at 11:02









Irakli

31




31




New contributor




Irakli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Irakli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Irakli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




marked as duplicate by Sergiy Kolodyazhnyy command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 11:26


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Sergiy Kolodyazhnyy command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 30 '18 at 11:26


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • @Sergiy I doubt this is a duplicate of How to Search for Files Recursively into Subdirectories. This one particularly asks how to print just the filename (without the path) while the other one asks for find in general.
    – PerlDuck
    Dec 30 '18 at 11:56












  • @PerlDuck Admittedly, the many top answers don't mention printing only filename without path, however IMHO it's a matter of reading the manual and adding proper flag to the command. I have, however, edited my own answer there to mention some of the flags find has, so hopefully that covers it. Alternatively, askubuntu.com/a/651321/295286 would probably be a more appropriate, and it pretty much same question in the title. Feel free to vote on reopening, though.
    – Sergiy Kolodyazhnyy
    Dec 30 '18 at 12:01










  • @SergiyKolodyazhnyy Congrats on command-line gold :) This seems more of a duplicate for printing basename only?
    – WinEunuuchs2Unix
    Dec 30 '18 at 14:46










  • @WinEunuuchs2Unix Hi, thanks. I've had command-line gold for about 2-3 years now. Check the list of duplicates to this post - there's two, How do you output the filename in find command while using -exec? addresses that issue.
    – Sergiy Kolodyazhnyy
    Dec 30 '18 at 22:53


















  • @Sergiy I doubt this is a duplicate of How to Search for Files Recursively into Subdirectories. This one particularly asks how to print just the filename (without the path) while the other one asks for find in general.
    – PerlDuck
    Dec 30 '18 at 11:56












  • @PerlDuck Admittedly, the many top answers don't mention printing only filename without path, however IMHO it's a matter of reading the manual and adding proper flag to the command. I have, however, edited my own answer there to mention some of the flags find has, so hopefully that covers it. Alternatively, askubuntu.com/a/651321/295286 would probably be a more appropriate, and it pretty much same question in the title. Feel free to vote on reopening, though.
    – Sergiy Kolodyazhnyy
    Dec 30 '18 at 12:01










  • @SergiyKolodyazhnyy Congrats on command-line gold :) This seems more of a duplicate for printing basename only?
    – WinEunuuchs2Unix
    Dec 30 '18 at 14:46










  • @WinEunuuchs2Unix Hi, thanks. I've had command-line gold for about 2-3 years now. Check the list of duplicates to this post - there's two, How do you output the filename in find command while using -exec? addresses that issue.
    – Sergiy Kolodyazhnyy
    Dec 30 '18 at 22:53
















@Sergiy I doubt this is a duplicate of How to Search for Files Recursively into Subdirectories. This one particularly asks how to print just the filename (without the path) while the other one asks for find in general.
– PerlDuck
Dec 30 '18 at 11:56






@Sergiy I doubt this is a duplicate of How to Search for Files Recursively into Subdirectories. This one particularly asks how to print just the filename (without the path) while the other one asks for find in general.
– PerlDuck
Dec 30 '18 at 11:56














@PerlDuck Admittedly, the many top answers don't mention printing only filename without path, however IMHO it's a matter of reading the manual and adding proper flag to the command. I have, however, edited my own answer there to mention some of the flags find has, so hopefully that covers it. Alternatively, askubuntu.com/a/651321/295286 would probably be a more appropriate, and it pretty much same question in the title. Feel free to vote on reopening, though.
– Sergiy Kolodyazhnyy
Dec 30 '18 at 12:01




@PerlDuck Admittedly, the many top answers don't mention printing only filename without path, however IMHO it's a matter of reading the manual and adding proper flag to the command. I have, however, edited my own answer there to mention some of the flags find has, so hopefully that covers it. Alternatively, askubuntu.com/a/651321/295286 would probably be a more appropriate, and it pretty much same question in the title. Feel free to vote on reopening, though.
– Sergiy Kolodyazhnyy
Dec 30 '18 at 12:01












@SergiyKolodyazhnyy Congrats on command-line gold :) This seems more of a duplicate for printing basename only?
– WinEunuuchs2Unix
Dec 30 '18 at 14:46




@SergiyKolodyazhnyy Congrats on command-line gold :) This seems more of a duplicate for printing basename only?
– WinEunuuchs2Unix
Dec 30 '18 at 14:46












@WinEunuuchs2Unix Hi, thanks. I've had command-line gold for about 2-3 years now. Check the list of duplicates to this post - there's two, How do you output the filename in find command while using -exec? addresses that issue.
– Sergiy Kolodyazhnyy
Dec 30 '18 at 22:53




@WinEunuuchs2Unix Hi, thanks. I've had command-line gold for about 2-3 years now. Check the list of duplicates to this post - there's two, How do you output the filename in find command while using -exec? addresses that issue.
– Sergiy Kolodyazhnyy
Dec 30 '18 at 22:53










1 Answer
1






active

oldest

votes


















4














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



Use:



find  -iname "*.html" -printf "%fn"


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 "





share|improve this answer























  • It's works, can you please tell me what's is %fn?
    – Irakli
    Dec 30 '18 at 11:14










  • %f file name, n, a new line.
    – Ravexina
    Dec 30 '18 at 11:16






  • 1




    @Irakli See manpages.ubuntu.com/manpages/bionic/man1/find.1.html and scroll down to -printf. There are various other %something flags you can use, e.g. %s for the file's size.
    – PerlDuck
    Dec 30 '18 at 11:19










  • "%fn" maybe better in case some filenames have spaces in them.
    – DK Bose
    Dec 30 '18 at 11:22


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














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



Use:



find  -iname "*.html" -printf "%fn"


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 "





share|improve this answer























  • It's works, can you please tell me what's is %fn?
    – Irakli
    Dec 30 '18 at 11:14










  • %f file name, n, a new line.
    – Ravexina
    Dec 30 '18 at 11:16






  • 1




    @Irakli See manpages.ubuntu.com/manpages/bionic/man1/find.1.html and scroll down to -printf. There are various other %something flags you can use, e.g. %s for the file's size.
    – PerlDuck
    Dec 30 '18 at 11:19










  • "%fn" maybe better in case some filenames have spaces in them.
    – DK Bose
    Dec 30 '18 at 11:22
















4














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



Use:



find  -iname "*.html" -printf "%fn"


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 "





share|improve this answer























  • It's works, can you please tell me what's is %fn?
    – Irakli
    Dec 30 '18 at 11:14










  • %f file name, n, a new line.
    – Ravexina
    Dec 30 '18 at 11:16






  • 1




    @Irakli See manpages.ubuntu.com/manpages/bionic/man1/find.1.html and scroll down to -printf. There are various other %something flags you can use, e.g. %s for the file's size.
    – PerlDuck
    Dec 30 '18 at 11:19










  • "%fn" maybe better in case some filenames have spaces in them.
    – DK Bose
    Dec 30 '18 at 11:22














4












4








4






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



Use:



find  -iname "*.html" -printf "%fn"


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 "





share|improve this answer














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



Use:



find  -iname "*.html" -printf "%fn"


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 "






share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 30 '18 at 11:16

























answered Dec 30 '18 at 11:11









Ravexina

31.4k1481110




31.4k1481110












  • It's works, can you please tell me what's is %fn?
    – Irakli
    Dec 30 '18 at 11:14










  • %f file name, n, a new line.
    – Ravexina
    Dec 30 '18 at 11:16






  • 1




    @Irakli See manpages.ubuntu.com/manpages/bionic/man1/find.1.html and scroll down to -printf. There are various other %something flags you can use, e.g. %s for the file's size.
    – PerlDuck
    Dec 30 '18 at 11:19










  • "%fn" maybe better in case some filenames have spaces in them.
    – DK Bose
    Dec 30 '18 at 11:22


















  • It's works, can you please tell me what's is %fn?
    – Irakli
    Dec 30 '18 at 11:14










  • %f file name, n, a new line.
    – Ravexina
    Dec 30 '18 at 11:16






  • 1




    @Irakli See manpages.ubuntu.com/manpages/bionic/man1/find.1.html and scroll down to -printf. There are various other %something flags you can use, e.g. %s for the file's size.
    – PerlDuck
    Dec 30 '18 at 11:19










  • "%fn" maybe better in case some filenames have spaces in them.
    – DK Bose
    Dec 30 '18 at 11:22
















It's works, can you please tell me what's is %fn?
– Irakli
Dec 30 '18 at 11:14




It's works, can you please tell me what's is %fn?
– Irakli
Dec 30 '18 at 11:14












%f file name, n, a new line.
– Ravexina
Dec 30 '18 at 11:16




%f file name, n, a new line.
– Ravexina
Dec 30 '18 at 11:16




1




1




@Irakli See manpages.ubuntu.com/manpages/bionic/man1/find.1.html and scroll down to -printf. There are various other %something flags you can use, e.g. %s for the file's size.
– PerlDuck
Dec 30 '18 at 11:19




@Irakli See manpages.ubuntu.com/manpages/bionic/man1/find.1.html and scroll down to -printf. There are various other %something flags you can use, e.g. %s for the file's size.
– PerlDuck
Dec 30 '18 at 11:19












"%fn" maybe better in case some filenames have spaces in them.
– DK Bose
Dec 30 '18 at 11:22




"%fn" maybe better in case some filenames have spaces in them.
– DK Bose
Dec 30 '18 at 11:22



Popular posts from this blog

Human spaceflight

Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

File:DeusFollowingSea.jpg