Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 19 Jun 2013, 12:59
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Search the whole computer for file from command line (Solved
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [14 Posts]  
Author Message
RoyBell

Joined: 07 Feb 2012
Posts: 41
Location: Leeds UK

PostPosted: Sun 11 Mar 2012, 10:31    Post subject:  Search the whole computer for file from command line (Solved
Subject description: How can I search everywhere including different partitions for a file using the command line
 

I was trying to find a file that I knew existed (lupus.528.004.iso) using the command line because I am trying to learn more.

Using:
Code:
find lupu*.iso

I get "No such file or directory"
I eventually tried:
Code:
find -name lupu*.iso

This found lupu-528.iso in:
Code:
/root/my-applications/bin/lupu-528.iso

However the file I am trying to find (lupu-528.004.iso) exists on the sda6 extension.
I can find it if I change directory to sda6 but I am trying to find out how to do a global search.

How can I instruct the command line to search the entire computer for a file without having to give it a clue?

Thanks in advance for any replies.
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 573

PostPosted: Sun 11 Mar 2012, 10:44    Post subject:  

Code:
find / | grep some_file_name

should do the trick.
/ indicates to search the entire filesystem.

EDIT: Note that the above syntax won't accept * as a wildcard.
But this one seems to work:
Code:
find / -name lupu*.iso


HTH
Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 3845

PostPosted: Sun 11 Mar 2012, 16:07    Post subject:  

find /usr /root /opt /etc -iname *string*

will search /usr /root /opt and /etc recursively for a file containing "string" in its name

(the reason I don't use / is because it will search /mnt and /initrd too, which may be undesirable if you had some large file systems mounted ... unless that is where they are Smile )

_________________
Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
RoyBell

Joined: 07 Feb 2012
Posts: 41
Location: Leeds UK

PostPosted: Mon 12 Mar 2012, 05:47    Post subject:  

Hi SFR,

I tried your fix but it only finds the file in "my-applications".
It doesn't find the one in the sda6 partition.

Hi technosaurus,

I'm trying to do a global search without giving pathmanes.
I just want to search the whole computer including other partitions.

Regards, to all. (I'm still trying)
Back to top
View user's profile Send private message 
Keef


Joined: 20 Dec 2007
Posts: 433
Location: Staffordshire

PostPosted: Mon 12 Mar 2012, 08:10    Post subject:  

Roy,
'find' starts at the directory it is launched from. To search everything, type 'cd' and it will take you to 'root'.
Now try this:
Code:
find  /  -name \*.iso

You can make the name more specific of course. This found all the isos I have buried in sda3.
Back to top
View user's profile Send private message 
RoyBell

Joined: 07 Feb 2012
Posts: 41
Location: Leeds UK

PostPosted: Mon 12 Mar 2012, 13:18    Post subject:  

Hi Keef,

Thanks very much for that.
It did the trick.

My next question is how did the back slash make the difference?

I'll be doing some more reading.

Thanks again, Roy.
Back to top
View user's profile Send private message 
Keef


Joined: 20 Dec 2007
Posts: 433
Location: Staffordshire

PostPosted: Mon 12 Mar 2012, 14:25    Post subject:  

Actually I don't really know! (just did a bit of quick googling).
Backslashes are usually used to 'escape' certain characters, but I think it is redundant in this case.

But I've just tried it without the '\' and it still works (faster too).
Code:
find  /  -name *.iso


or try

Code:
find / -name "*.iso"


and see if there is any difference. Just remember to run from the top level.

Have a read of this:
http://ss64.com/bash/find.html
Especially the examples near the bottom.
Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 9910
Location: Arizona USA

PostPosted: Mon 12 Mar 2012, 15:34    Post subject:  

How can it find a file in a partition that is not mounted? Shocked
Back to top
View user's profile Send private message 
RoyBell

Joined: 07 Feb 2012
Posts: 41
Location: Leeds UK

PostPosted: Mon 12 Mar 2012, 15:57    Post subject:  

Hi Keef,

Looking back through my list of command line searches it seems that I had used the solution already but there is a twist.

I had downloaded the file lupu-528.004.iso but somehow it disappeared.
When I realized that I had lost it I created a substitute with a similar filename.
So some of my searches were done when the file was missing.

Maybe I lost the file when I tried (unsuccessfully) to burn it to a CD?
I can't explain where its gone!

The search you suggested works without the back slash.

Hi Flash,

The search does indeed find the file even though the partition is not mounted. I guess its normal to see it without mounting.

Thanks to all.

How do I now mark this thread as solved?
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 841

PostPosted: Mon 12 Mar 2012, 18:19    Post subject:  

RoyBell wrote:

The search does indeed find the file even though the partition is not mounted. I guess its normal to see it without mounting.

Thanks to all.

How do I now mark this thread as solved?


RoyBell,

Just to clariify -

The command "find" will only search in mounted drives. So the drives or partitions must be mounted first.

Cheers,
s
Back to top
View user's profile Send private message 
RoyBell

Joined: 07 Feb 2012
Posts: 41
Location: Leeds UK

PostPosted: Wed 14 Mar 2012, 02:16    Post subject:  

Hi seaside,

I have just checked again that sda6 was not mounted and the working directory was "root", then I did a search for the file that is in there.
The search:
Code:
find / -name lupu*.iso

found the file in the sda6 partition.

I'm puzzled now!

Is it possible that the system sees the partition as mounted but tells us mere humans that it is not so that we don't do anything silly!!

Does Puppy Linux do things differently with the command line?

Can anyone explain!

Regards, Roy.

(I can see sda6 with the GUI file manager without mounting)
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 3845

PostPosted: Wed 14 Mar 2012, 09:42    Post subject:  

simply clicking on the icon will mount in puppy by default, this behavior is/was configurable
_________________
Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 841

PostPosted: Wed 14 Mar 2012, 09:44    Post subject:  

RoyBell wrote:

(I can see sda6 with the GUI file manager without mounting)


RoyBell,

My guess is that it is mounted. You can check by opening a terminal and typing "df". Look at the far right column; it would show there if mounted.

Cheers,
s
Back to top
View user's profile Send private message 
RoyBell

Joined: 07 Feb 2012
Posts: 41
Location: Leeds UK

PostPosted: Thu 15 Mar 2012, 03:20    Post subject:  

Hi seaside,

I have done a "df" after switching on and there is no mention of sda6.
I get:

Quote:
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 18789684 813592 17021624 5% /
/dev/root 18789684 813592 17021624 5% /
shmfs 244956 0 244956 0% /dev/shm


When I mount the sda6 partition, a Green dot appears on the icon to indicate that its mounted.
So I know that its not mounted on start-up.
I've also clicked on the "Mount" icon and checked that its not mounted.

Roy.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [14 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0745s ][ Queries: 12 (0.0101s) ][ GZIP on ]