Comments on Finding Files On The Command Line
Finding Files On The Command Line One of the things I like about Linux is the command line. I have used nautilus, gnome-commander, konqueror, kommander, dolphin and thunar to manage files in Linux and these file managers are great for what they do. But there are times when one simply wants to find a file when working on the command line without having to open a GUI application.
11 Comment(s)
Comments
Re: Find and delete using only find Submitted by Anonymous (not registered) on Tue, 2009-09-08 23:39.
Command line? You mean like the old days of DOS? Does that come complete with a mono-chrome green-screen monitor? Wow, talk about antiquated and obsolete.
-------------------------
This is not for DOS. He talking about CLI ( command line interface or / and command line interpreter ) for linux. This is a SHEL. You can read more here -> http://en.wikipedia.org/wiki/Command-line_interpreter
Great tutorial.
Here is how you can find large files (or files larger then %)
find / -type f -size +10000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'You could use -amin, -cmin and -mmin to improve granularity in searches.
In -amin, -cmin and -mmin n is number of minutes, so you can search files accessed/created/modified in the last 5 minutes for example.
An alternative way to find and delete files using only find.
find /path -name mytestfile -exec rm '{}' \;
Everything between -exec and \; get executed per file, and '{}' is replaced with the name of the file found.
This can be used to do just about anything with files. So for example, find and delete all CVS folders in a project:
find /path -name CVS -type d -exec rm -r '{}' \;
Create and md5 hash of all files in a folder
find /home/williamb/ -type f -exec md5sum '{}' \;
Possibilities are endless...
Command line? You mean like the old days of DOS? Does that come complete with a mono-chrome green-screen monitor? Wow, talk about antiquated and obsolete.
Command line is not for you Anonymous. Don't use it! If you can't click on it it does not exist for you.
To significantly speed up deletion of large numbers of files, finish the find command with a +, not a \;, thus:
find /path -iname "*somefile*" -exec rm "{}" +
Find and Copy files?
Useful article!
I find the "find" command very useful when some databases get corrupted. I use:
find /var/db/mysql -name "*.MYI" -exec myisamchk -r '{}' \;
It works like a charm ;)
Nice info, Here
Here is a way to convert the command to vbs file to search files.
http://www.funbutlearn.com/2012/08/the-easy-way-to-search-files-search.html
Immensely frustrating when I want to find a type of file, edited only a few days ago and has a particular fragment of text. I just can't see anything that will do it (and get somebody elses project going again)