parsed.org

Tips by tag: find

Copying a filesystem by xinu on Jan 12, 2005 10:59 AM

Here is a way to copy an entire filesystem without descending down its subsumed mount points. This example uses the root filesystem:

$ find / -xdev | cpio -pm /desired/location
commandscopycpiofilesystemfindrootshell
Display files by size by http://felicity.me.uk/ on Apr 28, 2008 02:08 PM

For example, to display the 20 largest files owned by joe:

find / -printf "%k\t%p\n" -user joe | sort -n | tail -20
commandsfilesfindpermissionsprintfsorttailusers
Find and Zip by xinu on Jan 12, 2005 10:59 AM

To zip up the contents of a directory (selectively), use find and zip:

$ find . -type f -name "*.jpg" | zip -@ myimages.zip
commandsdirectoryfindshellzip
Locating Files by cygnus on Mar 07, 2005 02:34 PM

Use slocate to build a database of files on your machine and use locate to find them:

# slocate -u # Rebuilds file database by scanning all filesystems
# locate foobar # finds all files with 'foobar' somewhere in the path
commandsdiagnosticfindslocateutilities
Xargs House-Cleaning by xinu on Jan 13, 2005 08:29 AM

If you have a bunch of files in your home directory and you want to push them into ~/sort, create the directory and then do the following:

$ find . -type f -maxdepth 1 ! -name ".?*" | xargs -I '{}' mv '{}' sort

Note: GNU xargs uses -i. BSD versions use -I.

bsdcommandsdirectoryfindgnushellsortxargs
RSS