You are not logged in.
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

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
Hello Gordon,
with the find command, for example:
find ~/ | grep imagefinds 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 magickor 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! -> Break your own...
VSIDO
LinuxCNC
Frugalware <- It's all just a kernel.
Offline
^ cool, never thought of doing that... how silly of me 
thanks for asking Flash!
Offline
Of course you can pipe the content of the search result into a file:
find ~/ | grep image > list.txtThere's another command called 'locate' (and slocate) but I never use it, so can't tell you anything about it.
Start Distrohopping here! -> Break your own...
VSIDO
LinuxCNC
Frugalware <- It's all just a kernel.
Offline
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 ) ? 
Cheers

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
Hi Folks.
Thanks for that just ran
sudo find / | grep magickand 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 ) ?
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
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! -> Break your own...
VSIDO
LinuxCNC
Frugalware <- It's all just a kernel.
Offline
Hi Folks
Thanks for them there instructions
:)
Cheers

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
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 updatedbI 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 | moreOr put the output in a file you can open with an editor
locate magick > xx
nano xxOffline
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 PATTERNOr if it's case sensitive:
find PATH -type f -name PATTERNOr if it's about directories:
find PATH -type d -iname PATTERNThe 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
^ Thanks Awebb, duly noted
But why not grepping?
Start Distrohopping here! -> Break your own...
VSIDO
LinuxCNC
Frugalware <- It's all just a kernel.
Offline
^ 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. 
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' 
Offline
^ All right, understood. And the results are the same? 
Start Distrohopping here! -> Break your own...
VSIDO
LinuxCNC
Frugalware <- It's all just a kernel.
Offline
^ 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.txtOffline
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! -> Break your own...
VSIDO
LinuxCNC
Frugalware <- It's all just a kernel.
Offline
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
:)
Cheers

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
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
:)
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
Hi Stanie.
Tried sudo updatedb and all I get is
sudo: updatedb: command not found Cheers

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
^ slocate -u should do the same.
Start Distrohopping here! -> Break your own...
VSIDO
LinuxCNC
Frugalware <- It's all just a kernel.
Offline
Hi machinebacon
Sorry to say I get the same results
bash: slocate: command not foundI get the above as root terminal or just in terminal
Cheers

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
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! -> Break your own...
VSIDO
LinuxCNC
Frugalware <- It's all just a kernel.
Offline
@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" | rmForks: 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 rmCount 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
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
:)
Cheers

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
@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-foundnext 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
'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 mlocateTo install:
sudo aptitude install mlocate(I prefer aptitude, replace with apt-get if you prefer
)
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.