Commands using find (1,107)

  • * Find all file sizes and file names from the current directory down (replace "." with a target directory as needed). * sort the file sizes in numeric order * List only the duplicated file sizes * drop the file sizes so there are simply a list of files (retain order) * calculate md5sums on all of the files * replace the first instance of two spaces (md5sum output) with a \0 * drop the unique md5sums so only duplicate files remain listed * Use AWK to aggregate identical files on one line. * Remove the blank line from the beginning (This was done more efficiently by putting another "IF" into the AWK command, but then the whole line exceeded the 255 char limit). >>>> Each output line contains the md5sum and then all of the files that have that identical md5sum. All fields are \0 delimited. All records are \n delimited.


    0
    find . -type f -not -empty -printf "%-25s%p\n"|sort -n|uniq -D -w25|cut -b26-|xargs -d"\n" -n1 md5sum|sed "s/ /\x0/"|uniq -D -w32|awk -F"\0" 'BEGIN{l="";}{if(l!=$1||l==""){printf "\n%s\0",$1}printf "\0%s",$2;l=$1}END{printf "\n"}'|sed "/^$/d"
    alafrosty · 2013-10-22 13:34:19 0

  • 0
    find *.less | xargs -I {} lessc {} {}.css && ls *.less.css | sed -e 'p;s/less.css/css/' | xargs -n2 mv
    ckrotcov · 2013-10-21 23:53:31 0
  • I _think_ you were trying to delete files whether or not they had spaces. This would do that. You should probably be more specific though.


    -1
    find garbage/ -type f -delete
    pdxdoughnut · 2013-10-21 23:26:51 1
  • When you do a ls -1 | xargs rm it wouldn't workd because those files have spaces. So you must use find -print0 and xargs -0


    -3
    find /Users/jpn/.ievms/ -type f -print0| xargs -0 du -sh
    unixmonkey39631 · 2013-10-16 09:54:19 1
  • Alternative to mnikhil's ls/awk solution


    1
    find . -user root
    jedifu · 2013-10-16 08:08:41 1

  • 2
    find -size +100M
    pdxdoughnut · 2013-10-07 18:16:14 0
  • If /home/sonic/archive/ was a symlink to /backup/sonic/archive it would follow the links and give you the file listing. By default find will NOT follow symbolic links. The default behavior for the find command is to treat the symlinks as literal files. I discovered this when trying to write a script run via cron to delete files with a modification time older than X days. The easiest solution was to use: /usr/bin/find -L /home/sonic/archive -name '*gz' -type f -mtime +14 -exec rm '{}' \; Show Sample Output


    -1
    find -L /home/sonic/archive -name '*gz' -type f
    sonic · 2013-10-07 14:32:22 0
  • Sorts by latest modified files by looking to current directory and all subdirectories Show Sample Output


    1
    find . -name '*pdf*' -print0 | xargs -0 ls -lt | head -20
    fuats · 2013-10-03 21:58:51 0

  • 0
    find .git/objects -type f -printf "%P\n" | sed s,/,, | while read object; do echo "=== $obj $(git cat-file -t $object) ==="; git cat-file -p $object; done
    hamador · 2013-10-02 09:09:00 0
  • Display a list of local shell scripts soft-linked to /usr/local/bin Put local shell scripts to local ~/bin/ directory and soft-link them to /usr/local/bin/ which is in the $PATH variable to run them from anywhere. Show Sample Output


    0
    for AAA in $(find /usr/local/bin -type l); do ls -gG "${AAA}"; done
    rgregor · 2013-10-01 10:49:12 0
  • "find ./ ..." could be replaced with "find $PWD ..." to display absolute path instead of relative path. Show Sample Output


    0
    find ./ -type f -size +500k -exec ls -1Ash {} \; | sort -hr | cat -n
    rgregor · 2013-10-01 10:32:28 0
  • Shows the OS X applications downloaded from App Store. Doesn't include manually added apps. Show Sample Output


    0
    find /Applications -path '*Contents/_MASReceipt/receipt' -maxdepth 4 -print |sed 's#.app/Contents/_MASReceipt/receipt#.app#g; s#/Applications/##'
    bugmenot · 2013-09-28 15:44:32 0
  • When trying to find an error in a hosted project it's interesting to find out how the source is organized: Are there .inc files? Or .php files only? Or .xml files that probably contain translated texts? Show Sample Output


    0
    find . -type f | perl -ne 'chop(); $ext = substr($_, rindex($_, ".") + 1); print "$ext\n";' | sort | uniq --count | sort -n
    t3o · 2013-09-26 07:45:19 0
  • Find's all png's in the current folder and all of its children pngcrushes all results. Destructive.


    0
    find -f . png | while read line; do pngcrush -ow -brute $line; done
    mildfuzz · 2013-09-25 13:40:14 0
  • This command is for producing GNU sha256sum-compatible hashes on UNIX systems that don't have sha256sum but do have OpenSSL, such as stock IBM AIX. 1.- Saves a wrapper script for UNIX find that does the following: A.- Feeds a file to openssl on SHA256 hash calculation mode B.- Echoes the output followed by the filename 2.- Makes the file executable 3.- Runs find on a directory, only processing files, and running on each one the wrapper script that calculates SHA256 hashes Pending is figuring out how to verify a sha256sum file on a similar environment. Show Sample Output


    0
    echo '#! /usr/bin/ksh\necho `cat $1 | openssl dgst -sha256` $1' > sslsha256; chmod +x sslsha256; find directory -type f -exec ./sslsha256 \{\} \;
    RAKK · 2013-09-18 17:37:50 0

  • 0
    find -name *.bak -print0 | du -hc --files0-from=-
    muffl0n · 2013-08-23 14:15:33 0

  • 0
    find . -name "*.h" -o -name "*.cpp" | xargs sed -i 's/addVertexes/addVertices/g'
    egeoffray · 2013-08-07 07:31:45 2
  • Goes through all files in the directory specified, uses `stat` to print out last modification time, then sorts numerically in reverse, then uses cut to remove the modified epoch timestamp and finally head to only output the last 10 modified files. Note that on a Mac `stat` won't work like this, you'll need to use either: find . -type f -print0 | xargs -0 stat -f '%m%t%Sm %12z %N' | sort -nr | cut -f2- | head or alternatively do a `brew install coreutils` and then replace `stat` with `gstat` in the original command. Show Sample Output


    5
    find . -type f -print0 | xargs -0 stat -c'%Y :%y %12s %n' | sort -nr | cut -d: -f2- | head
    HerbCSO · 2013-08-03 09:53:46 2

  • -4
    find . -type f -exec md5sum {} \;
    qistoph · 2013-07-30 08:56:07 1
  • For each directory from the current one, list the counts of files in each of these directories. Change the -maxdepth to drill down further through directories. Show Sample Output


    2
    find . -maxdepth 1 -type d -exec sh -c "printf '{} ' ; find '{}' -type f -ls | wc -l" \;
    HerbCSO · 2013-07-29 19:46:35 0
  • basic find implementation for systems that don't actually have find, like an android console without busybox installed.


    3
    find (); { ls $1 | while read line; do [[ -d $1/$line ]] && find $1/$line $2 || echo $1/$line | grep $2; done; }
    a8ksh4 · 2013-07-28 22:21:39 0

  • 0
    find $(YourPATH) -type f -exec dos2unix '{}' \;
    chenhow1985 · 2013-07-26 09:07:35 0
  • It eases the way of creating cron jobs of backup scripts. Just put this line as cron job, and all your backups are called sequentially. Allows you to forget, when in time, call this backup, just focus on your scripting. Also maintains the way of calling a single backup script when It's needed.


    0
    find /var/scripts -name 'backup*' -exec {} ';'
    piscue · 2013-07-24 21:25:21 2
  • bash-3.2$ find /logs -ls -xdev | sort -nrk 7 | head -10 1761905 205380 -rwxrwxr-x 1 wsadmin logadmin 210095353 Jul 22 01:33 /logs/intlpymt/Trace.log 652689 187360 -rwxrwxr-x 1 wsadmin logadmin 191663182 Jul 21 23:00 /logs/websphere/wsfpp1lppwa1213omsecureServer/SystemOut_13.07.21_23.00.12.log 2380449 186536 -rwxrwxr-x 1 wsadmin logadmin 190819939 Jul 16 14:03 /logs/omset/traceIntl.log.201307161403.lppwa1213.gz 2119524 183888 -rwxrwxr-x 1 wsadmin logadmin 188110111 Jul 22 01:33 /logs/intlpymt/intlpymtria/Trace.log 652816 160332 -rwxrwxr-x 1 wsadmin logadmin 164011871 Aug 14 2012 /logs/websphere/wsfpp1lppwa1213omsecureServer/SystemOut.log_08142012.gzip 653312 128916 -rwxrwxr-x 1 wsadmin logadmin 131873943 Jul 18 10:49 /logs/websphere/heapdump.20130718.104150.27592.0006.phd.201307181406.lppwa1213.gz 653320 128916 -rwxrwxr-x 1 wsadmin logadmin 131873735 Jul 18 10:40 /logs/websphere/heapdump.20130718.104012.27592.0002.phd.201307181406.lppwa1213.gz 653309 128912 -rwxrwxr-x 1 wsadmin logadmin 131867602 Jul 18 10:46 /logs/websphere/heapdump.20130718.104008.27592.0001.phd.201307181405.lppwa1213.gz 653323 128872 -rwxrwxr-x 1 wsadmin logadmin 131828157 Jul 18 10:41 /logs/websphere/heapdump.20130718.104109.27592.0004.phd.201307181407.lppwa1213.gz 652783 120288 -rwxrwxr-x 1 wsadmin logadmin 123047750 Aug 13 2012 /logs/websphere/wsfpp1lppwa1213omsecureServer/SystemOut.log_0813.2012.gzip bash-3.2$ Show Sample Output


    0
    find /logs -ls -xdev | sort -nrk 7 | head -10
    vidya99343 · 2013-07-22 08:36:03 0

  • 0
    find /logs -ls -xdev | sort -nrk 7 | head -10
    vidya99343 · 2013-07-22 08:34:28 0
  • ‹ First  < 5 6 7 8 9 >  Last ›

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: