LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-21-2022, 07:46 PM   #1
LinuxEmachine
LQ Newbie
 
Registered: Mar 2021
Distribution: Lubuntu 20.04 LTS
Posts: 24

Rep: Reputation: Disabled
"Find" command not finding a folder that I know exists


I'm having trouble with the "find" command. I had a folder on my desktop, deleted it by accident, and so I restored it from the "trash" gui. Then I used the gui to perform a find command on that folder, I specified the desktop directory, and it can't find the folder (it's right in front of me!) For testing purposes, I even created a folder called "testing 123" on my desktop, used the gui find feature, and it found that folder.

When something goes to the trash bin, and is restored, does it confuse linux?

I tried running "find" by command line, and it still returned no results. But when I used the "find" command on that "testing 123 folder", it found it.

I can't understand why the find command can't detect this folder when it's right there on my desktop. Thanks, Matt
 
Old 11-21-2022, 11:06 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Please specify the actual name of the 'restored' dir and show the cli cmd you used and it's output - exactly.
Ie please copy and paste, instead of describing.
 
1 members found this post helpful.
Old 11-22-2022, 01:34 AM   #3
LinuxEmachine
LQ Newbie
 
Registered: Mar 2021
Distribution: Lubuntu 20.04 LTS
Posts: 24

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
Please specify the actual name of the 'restored' dir and show the cli cmd you used and it's output - exactly.
Ie please copy and paste, instead of describing.
matt@matt-aspirexc830:~$ find /home/matt/Desktop -name "matt birthday videos (1982) [1080p]"
matt@matt-aspirexc830:~$

Out of curiosity, I shortened the name of that folder, leaving off the [1080p]. Then I ran the command on it:

matt@matt-aspirexc830:~$ find /home/matt/Desktop -name "matt birthday videos (1982)"
/home/matt/Desktop/matt birthday videos (1982)
matt@matt-aspirexc830:~$

You see, now it can find it. Why is that?
 
Old 11-22-2022, 02:44 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
most probably there is a hidden char somewhere (or something similar happened). How did you create that original dir?
You need to accept: find is correct, the name you passed to find is not identical to the real name.
 
1 members found this post helpful.
Old 11-22-2022, 03:01 AM   #5
lvm_
Member
 
Registered: Jul 2020
Posts: 944

Rep: Reputation: 338Reputation: 338Reputation: 338Reputation: 338
Square brackets are special regex characters, they must be escaped: "\[1080p\]"
 
2 members found this post helpful.
Old 11-22-2022, 03:20 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
Code:
$ ls -l
total 0
$ touch '[fgd]'
$ find . -name '[fgd]'
$ find . -name '.fgd.'
$ ls -l
total 0
-rw-r--r-- 1 user group 0 Nov 22 10:11 [fgd]
$ find . -name '.*fgd.*'
$ find . -name '*fgd*'
./[fgd]
$ find . -name '\[fgd\]'
./[fgd]
$
 
Old 11-22-2022, 09:23 AM   #7
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554
Quote:
Originally Posted by LinuxEmachine View Post
I shortened the name of that folder, leaving off the [1080p]. Then I ran the command on it:
...

You see, now it can find it. Why is that?
The -name argument accepts a glob pattern - see man glob for details.

You could have searched for "-name 'matt *'" and it would find the bracketed version.

(Note: glob patterns and regex patterns are different things, despite both having character classes.)

 
Old 11-22-2022, 10:31 PM   #8
LinuxEmachine
LQ Newbie
 
Registered: Mar 2021
Distribution: Lubuntu 20.04 LTS
Posts: 24

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
most probably there is a hidden char somewhere (or something similar happened). How did you create that original dir?
You need to accept: find is correct, the name you passed to find is not identical to the real name.
That folder I created in the Lubuntu gui desktop by right-clicking, create new folder. But I have a lot of folders where there are brackets in the filenames.

Quote:
Originally Posted by lvm_ View Post
Square brackets are special regex characters, they must be escaped: "\[1080p\]"
Awesome, that worked, thank you!

matt@matt-aspirexc830:~$ find /home/matt/Desktop -name "matt birthday videos (1982) \[1080p\]"
/home/matt/Desktop/matt birthday videos (1982) [1080p]
matt@matt-aspirexc830:~$

Now I know how to find files. I was backing up some folders/contents and in a hurry, and I dragged a folder to the wrong directory that I didn't recall where. Then I'm thinking, I have a 1.8gb file wasting valuable space somewhere on my solid state hard drive. Now I'm able to find that file and delete it.
 
Old 11-23-2022, 10:22 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
When working on *nix of any sort , avoid using whitespace or any kind of bracket/parentheses in a file name ie [] or () or {}.
Also other 'special' chars/punctuation - you'll thank us later
 
Old 11-24-2022, 05:52 AM   #10
Debian6to11
Member
 
Registered: Jan 2022
Location: Limassol, Cyprus
Distribution: Debian
Posts: 382
Blog Entries: 1

Rep: Reputation: 71
Quote:
Originally Posted by chrism01 View Post
When working on *nix of any sort , avoid using whitespace or any kind of bracket/parentheses in a file name ie [] or () or {}.
Also other 'special' chars/punctuation - you'll thank us later
Personally I use dashes and dots in file names.

I want to ask though, why does my Debian 11 (Cinnamon) does use brackets () and space when duplicating files.
Example: someFile > someFile (copy)
 
Old 11-24-2022, 07:17 AM   #11
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554
Quote:
Originally Posted by Debian6to11 View Post
I want to ask though, why does my Debian 11 (Cinnamon) does use brackets () and space when duplicating files.
Why shouldn't it?

It's a good idea to avoid non-printing characters and newlines, but any other characters are generally either a non-issue or not a big deal.

There can be specific situations where it makes life easier to constrain filenames for that context, and it's probably worth limiting filenames to characters that one's keyboards can produce, but it's not the case that people need to never use spaces or symbols.


Quote:
Originally Posted by LinuxEmachine View Post
Then I'm thinking, I have a 1.8gb file wasting valuable space somewhere on my solid state hard drive. Now I'm able to find that file and delete it.
find /home/matt -size +1G

(Also, KDE Filelight or ncdu or a whole bunch of similar apps.)

 
1 members found this post helpful.
Old 11-24-2022, 05:52 PM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Yeah, dots/dashes/hyphens are fine - especially for multi-word filenames.

The effect you are getting ie blah(copy) is because you can't have 2 identically named files (or dirs or symlinks ... etc) in the same dir, so if you don't specify a different name, the GUI app (!) will attempt to create something related/meaningful for you.
Note that in the shell it simply says
Code:
cp  t.t t.t
cp: 't.t' and 't.t' are the same file
ie it'll refuse.
What you're seeing is an artefact of the particular GUI program you are running.

HTH
 
  


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
directory exists but no such directory exists yumito Linux - Newbie 3 06-09-2013 02:02 AM
[SOLVED] "command not found" but the file file exists! r1d3r Ubuntu 5 04-29-2012 07:53 PM
Help With Java Problem Please"""""""""""" suemcholan Linux - Newbie 1 04-02-2008 06:02 PM
To exists or not to exists, this is the Q. Inbal Linux - Newbie 3 07-18-2006 06:04 AM
SIOCADDRT: File exists SIOCCADDRT: File Exists Failed to bring up eth0. opsraja Linux - Networking 0 01-10-2005 08:29 AM

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

All times are GMT -5. The time now is 05:23 AM.

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