SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2012-06-01 14:54:15

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 223

File Lists [ SOLVED ]

Hi Folks

I hope this post is in the right place.

How do I get a list of specific files lets say imagemagick for instance when you don't know where they are.

Last edited by Gordon (2012-06-01 20:47:30)


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

Help fund CrunchBang, donate to the project!

#2 2012-06-01 14:57:25

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,271
Website

Re: File Lists [ SOLVED ]

Hello Gordon,
with the find command, for example:

find ~/ | grep image

finds all files named (or including the string) image in the folder ~/ (that's your home folder)

To find files system-wide, you need to prepend a sudo, because some folders are for root access only.

sudo find / | grep magick

or you use the search assistant Catfish (should be in the menu -> Accessories).

You can include the catfish-search in gmrun (that's the dialog that pops up when you press Alt-F2) -> http://crunchbanglinux.org/wiki/howto/s … andcatfish

Last edited by machinebacon (2012-06-01 14:58:27)


Start Distrohopping here! -> Roast your ownVSIDO | LinuxCNC | AntiX | <-

Keep it what way?

Offline

#3 2012-06-01 15:05:23

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: File Lists [ SOLVED ]

^ cool, never thought of doing that... how silly of me smile
thanks for asking Flash!

Offline

#4 2012-06-01 15:24:44

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,271
Website

Re: File Lists [ SOLVED ]

Of course you can pipe the content of the search result into a file:

find ~/ | grep image > list.txt

There's another command called 'locate' (and slocate) but I never use it, so can't tell you anything about it.


Start Distrohopping here! -> Roast your ownVSIDO | LinuxCNC | AntiX | <-

Keep it what way?

Offline

#5 2012-06-01 15:39:10

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 223

Re: File Lists [ SOLVED ]

Hi Folks.

Thanks for that just ran

sudo find / | grep magick 

and frightened myself to death with the amount of files it found.

Is there a way of limiting it to list only the main one ( the one that you download ) ? smile


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

#6 2012-06-01 16:13:30

Stanie
#! CrunchBanger
Registered: 2011-12-20
Posts: 225

Re: File Lists [ SOLVED ]

Gordon wrote:

Hi Folks.

Thanks for that just ran

sudo find / | grep magick 

and frightened myself to death with the amount of files it found.

Is there a way of limiting it to list only the main one ( the one that you download ) ? smile

Sure you can do it. Don't use the sudo find command unless you need to search system-wide (e.g. also in your root partition). You can limit the search for a specific folder - like for example

find ~/downloads | grep magick


A secure alternative to Dropbox with complete privacy = SpiderOak. Join it using my referral and get a total of 3 GB to start with.

Offline

#7 2012-06-01 16:19:36

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,271
Website

Re: File Lists [ SOLVED ]

Gordon,

just for your information:

/ is the whole folder where everything sits inside (/usr, /etc, /home, /media, /mnt, /var, ...)
~/ is only the home/username/ folder


Start Distrohopping here! -> Roast your ownVSIDO | LinuxCNC | AntiX | <-

Keep it what way?

Offline

#8 2012-06-01 20:46:54

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 223

Re: File Lists [ SOLVED ]

Hi Folks

Thanks for them there instructions smile:)


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

#9 2012-06-01 20:56:11

pidsley
#! Die Hard
Registered: 2012-05-23
Posts: 1,442

Re: File Lists [ SOLVED ]

machinebacon wrote:

There's another command called 'locate' (and slocate) but I never use it, so can't tell you anything about it.

locate is much faster than find, because it scans a database rather than looking at your hard drive. The downside is that you must update this database on a regular basis, especially after you install new software. But updating the database is easy and quick; just

sudo updatedb

I just did an update on my 160 G drive and it took 6.5 seconds. I never use find anymore, just locate. And if it returns more info than you like, you can always pipe it to "more" so you can see one screen at a time

locate magick | more

Or put the output in a file you can open with an editor

locate magick > xx
nano xx

Want Waldorf, but with sid and systemd? Try Darkside.

Offline

#10 2012-06-01 21:11:43

Awebb
The Singularity
Registered: 2009-07-23
Posts: 2,812

Re: File Lists [ SOLVED ]

Excuse my french, but anyone grepping find output should be forced to watch episode after episode of my little pony.

find PATH -type f -iname PATTERN

Or if it's case sensitive:

find PATH -type f -name PATTERN

Or if it's about directories:

find PATH -type d -iname PATTERN

The pattern must be complete, so use a regex * on both ends and escape the * if needed.

find / -type f -iname "*magick*"

I'm so meta, even this acronym

Offline

#11 2012-06-01 21:25:34

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,271
Website

Re: File Lists [ SOLVED ]

^ Thanks Awebb, duly noted smile But why not grepping?


Start Distrohopping here! -> Roast your ownVSIDO | LinuxCNC | AntiX | <-

Keep it what way?

Offline

#12 2012-06-01 22:48:45

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: File Lists [ SOLVED ]

^ i'm guessing here, but: everytime somebody greps the output of find, God kills a cute nerdy girl. same with using regex to parse html. it's just not OK. big_smile

nah the point is (i think) that you use find and grep, two apps, while you could just use the builtin options for find to do the same thing. KISS and all, you know. you don't do 'for i in *; do echo "$i"; done' when you can just type 'ls' smile

Offline

#13 2012-06-01 22:55:56

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,271
Website

Re: File Lists [ SOLVED ]

^ All right, understood. And the results are the same? smile


Start Distrohopping here! -> Roast your ownVSIDO | LinuxCNC | AntiX | <-

Keep it what way?

Offline

#14 2012-06-01 23:08:15

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: File Lists [ SOLVED ]

^ just tested it out, results are different, but makes sense, since i used the '-type f' option for find which only shows files... when grep just gives you both files and directories... wait, let's try something more...

they differ a little bit. i think mainly because when you do 'find -type f' followed by 'find -type d' then compare that to a full 'grep' list, grep is gonna list the files inside the directories too while find is skipping over those... so it seems find is also more efficient, not actually showing you files that don't have 'magick' in their name.

if you wanna do the test yourself:

sudo find / -type f -iname "*magick*" > find_native.txt
sudo find / -type d -iname "*magick*" >> find_native.txt
sudo find / | grep "magick" > find_grep.txt
diff -y find_grep.txt find_native.txt

Offline

#15 2012-06-01 23:21:07

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,271
Website

Re: File Lists [ SOLVED ]

Phew, here they differ quite a lot (have a try, ~/ directory with search string "*mal*" in native and "mal" in grep)

find ~/ -type f -iname "*mal*" > find_native.txt
find ~/ -type d -iname "*mal*" >> find_native.txt
find ~/ | grep "mal" > find_grep.txt
diff -y find_grep.txt find_native.txt

(on my system I have a ~/.thumbnails/normal folder, and its content is completely ignored by native find)


Start Distrohopping here! -> Roast your ownVSIDO | LinuxCNC | AntiX | <-

Keep it what way?

Offline

#16 2012-06-02 11:30:43

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 223

Re: File Lists [ SOLVED ]

Hi Folks

I Tried all them commands and there is certainly a lot of differences between the two.

pidsley

You were on about locate and slocate, I tried those but with no luck so I assume that I have to create some sort of database.

Please tell me where and how smile:)


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

#17 2012-06-02 12:12:40

Stanie
#! CrunchBanger
Registered: 2011-12-20
Posts: 225

Re: File Lists [ SOLVED ]

Gordon wrote:

Hi Folks

I Tried all them commands and there is certainly a lot of differences between the two.

pidsley

You were on about locate and slocate, I tried those but with no luck so I assume that I have to create some sort of database.

Please tell me where and how smile:)

Try sudo updatedb
If you want to use it with gui like Catfish and include also hidden files or even your system folders in your results, change the execute command in openbox menu to

catfish --fileman=thunar --path=/ --hidden --method=locate

EDIT: Found an interesting tutorial on YouTube about locate, database and catfish - you can even add external hard drives into your locate database...

Last edited by Stanie (2012-06-02 12:50:12)


A secure alternative to Dropbox with complete privacy = SpiderOak. Join it using my referral and get a total of 3 GB to start with.

Offline

#18 2012-06-03 07:39:01

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 223

Re: File Lists [ SOLVED ]

Hi Stanie.

Tried sudo updatedb and all I get is

 sudo: updatedb: command not found 

Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

#19 2012-06-03 10:00:03

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,271
Website

Re: File Lists [ SOLVED ]

^ slocate -u should do the same.


Start Distrohopping here! -> Roast your ownVSIDO | LinuxCNC | AntiX | <-

Keep it what way?

Offline

#20 2012-06-03 10:18:17

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 223

Re: File Lists [ SOLVED ]

Hi machinebacon

Sorry to say I get the same results

bash: slocate: command not found

I get the above as root terminal or just in terminal


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

#21 2012-06-03 10:34:07

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,271
Website

Re: File Lists [ SOLVED ]

Then it needs to be installed, with sudo apt-get install slocate or sudo apt-get install locate (I guess locate will do)


Start Distrohopping here! -> Roast your ownVSIDO | LinuxCNC | AntiX | <-

Keep it what way?

Offline

#22 2012-06-03 11:10:50

Awebb
The Singularity
Registered: 2009-07-23
Posts: 2,812

Re: File Lists [ SOLVED ]

@machinebacon:

1. every time you grep, a process is forked. Why fork a process, if the same functionality can be found in the original process?
2. In fact (or as far as I remember or at least let's assume), grep forks itself line by line to continue scanning while outputting. It would be damn slow otherwise. This is okay, if all you want is some output, but the moment you pipe it to another program, there will be more forking. It's like a big, organized, process ID based gangbang.
3. You will want to do something with your discovery most of the time. Using find's filters and -exec option, a line could look like this:

find /home -iname "xbmc*2011*log" -exec rm {} \;

Now let's grep it, shall we? Of course, we want a detailed string to be looked up, so it's egrep:

find /home | egrep "^xbmc.*2011.*log" | rm

Forks: 1 + n, while n is the number of results.

That would create one process for find, two or more egrep processes (due to it's efficient nature) and one rm process per entry we find. If the list is long enough, won't have to worry about feeding the hungry anymore, because everybody will have a fork then. Oh, wait, due to rm's incompetence as a valid unix tool, it cannot read from stdin. We'd have to cheat a little:

find /home | egrep "^xbmc.*2011.*log" | xargs rm

Count the forks. You'll come up at a lower count, but what do you have to think about?


I'm so meta, even this acronym

Offline

#23 2012-06-03 11:19:17

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 223

Re: File Lists [ SOLVED ]

Hi machinebacon

Thanks for that, I thought it was part of #! and that I was doing something wrong. Got it now thought and it is certainly quick smile:)


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

#24 2012-06-03 11:25:30

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: File Lists [ SOLVED ]

@Gordon: i got an app that will help you out a bit, i think. i know it did for me.

sudo apt-get install command-not-found

next time you type a wrong command, it will check for possibilities of what you meant and suggest them to you. it's the friendlier, more helpful version of the regular 'command not found'.

Offline

Help fund CrunchBang, donate to the project!

#25 2012-06-03 12:53:14

shem
Member
From: Universe 6.62606957(29)×10−34
Registered: 2012-05-16
Posts: 21

Re: File Lists [ SOLVED ]

'mlocate' is another good choice. It replaces 'locate'. Still uses 'updatedb' to make the database & 'locate' for searches. For more info about why it's better:

apt-cache show mlocate

To install:

sudo aptitude install mlocate

(I prefer aptitude, replace with apt-get if you prefer tongue)

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo