LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-10-2022, 03:44 PM   #1
peter7089
Member
 
Registered: May 2016
Distribution: MX Linux
Posts: 249

Rep: Reputation: Disabled
find command won't find files


I have a case in which i am trying to find files that have specific word in their names but for some reason it doesn't work. This is just example of how i use the 'find' command and i don't know why it won't find the file:

Code:
user@mx:~/Downloads/Torrent
$ ll
total 16K
-rwx------ 1 user user 14K Feb 19  2021 'Ubuntu Mate.torrent'
user@mx:~/Downloads/Torrent
$ find . -name Ubuntu
user@mx:~/Downloads/Torrent
$ find . -iname Ubuntu
user@mx:~/Downloads/Torrent
 
Old 01-10-2022, 03:47 PM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Use a glob with -name
Code:
find -name Ubuntu\*
See 2.2.1 Base Name Patterns in the GNU Findutils manual.

Last edited by shruggy; 01-10-2022 at 03:50 PM.
 
Old 01-10-2022, 03:49 PM   #3
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,600

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546

Because -name specifies a pattern that must match the whole filename (excluding path).

i.e. use "find . -name 'Ubuntu*'" for filenames that start with Ubuntu.


Last edited by boughtonp; 01-10-2022 at 03:51 PM.
 
Old 01-10-2022, 05:05 PM   #4
larstrier
Member
 
Registered: Dec 2019
Distribution: Debian
Posts: 97

Rep: Reputation: 24
Quote:
Originally Posted by peter7089 View Post
Code:
$ find . -name Ubuntu
Code:
$ find . -iname Ubuntu
You're not using the 'quote marks' and the "double quote" marks correctly.

See how boughtonp uses it effortlessly:

Code:
i.e. use "find . -name 'Ubuntu*'" for filenames that start with Ubuntu.
Use the quote marks when seeking directories with the 'find' command
 
Old 01-10-2022, 10:54 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
In other words, surround match with single quote marks (') to prevent shell interpolation of wildcard chars like '*'
Code:
find . -name 'Ubuntu*'
which matches names that start with Ubuntu and in exact case sensitivity.
Case in-sensitive uses '-iname' instead of '-name'
The man page is pretty comprehensive eg https://linux.die.net/man/1/find ; loads(!) of options for tweaking the find cmd.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 05:30 PM
Single find command to find multiple files? thok Linux - Newbie 7 01-31-2009 04:45 PM
Using a single "Find" Command to find files bases on multiple criteria roboxooo Linux - Newbie 6 01-15-2009 04:13 AM
in copy files or ls files the command want to invert select some files how to?? hocheetiong Linux - Newbie 3 06-27-2008 06:32 AM
How to find files and copy the found files to the floppy in one command justmehere Linux - Newbie 11 05-04-2008 11:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration