
Terminal - Commands tagged find - 369 results
This is sample output - yours may be different.
I use this find command example to find out all the executable files you can modify it to find readonly file as well.
find ./ -type f -size +100000k -exec ls -lh {} \; 2>/dev/null| awk '{ print $8 " : " $5}'
This is sample output - yours may be different.
[email protected]:~/test$ ls -sh
total 392M
102M 101MB_file 201M 200MB_file 91M 90MB_file
[email protected]:~/test$ find ./ -type f -size +100000k -exec ls -lh {} \; 2>/dev/null| awk '{ print $8 " : " $5}'
./101MB_file : 101M
./200MB_file : 200M
This command does a basic find with size. It also improves the printout given (more clearer then default)
Adjusting the ./ will alter the path.
Adjusting the "-size +100000k" will specify the size to search for.
find /etc/ /pentest/ -type f -iname "*sql*" | grep map
This is sample output - yours may be different.
[email protected]:~# find /etc/ /pentest/ -type f -iname "*sql*" | grep map
/pentest/enumeration/lanmap2/data/map-TCP-SYN.sql
/pentest/enumeration/lanmap2/data/map-IPv4.sql
/pentest/enumeration/lanmap2/data/map-DNS-TXT.sql
/pentest/enumeration/lanmap2/data/gen-db.sql
/pentest/enumeration/lanmap2/data/map-BOOTP-VendorClass.sql
/pentest/enumeration/lanmap2/data/map-BOOTP-Fingerprint.sql
/pentest/enumeration/lanmap2/data/map-ICMP-Echo-Fingerprint.sql
/pentest/enumeration/lanmap2/data/map-CDP.sql
/pentest/enumeration/lanmap2/data/map-BROWSE.sql
/pentest/enumeration/lanmap2/data/map-SSDP.sql
/pentest/enumeration/lanmap2/lib/libluasqlite3-loader.lua.in
you can find a special things(with defined -iname "*sql*") from in most of one direcroty(for example from both /etc/ and /pentest/) and then you can want to grep only include "map" word
find /pentest/ -type f -iname "*trace*"
This is sample output - yours may be different.
/pentest/misc/dradis/server/config/initializers/backtrace_silencers.rb
/pentest/misc/dradis/server/vendor/plugins/wiki_import/test/vendor/mocha-0.9.5/lib/mocha/backtrace_filter.rb
/pentest/enumeration/irpas/itrace.c
/pentest/enumeration/irpas/tctrace
/pentest/enumeration/irpas/itrace
/pentest/enumeration/irpas/itrace.o
/pentest/enumeration/irpas/tctrace.o
/pentest/enumeration/irpas/tctrace.c
/pentest/enumeration/0trace/0trace.sh
/pentest/enumeration/web/whatweb/plugins/TraceWatch.rb
/pentest/exploits/framework2/src/impurity/tracepath.c
/pentest/python/impacket-examples/tracer.py
/pentest/web/mantra/data/extensions/[email protected]/chrome/skin/classic/firecookieTrace.css
/pentest/web/mantra/data/extensions/[email protected]/skin/classic/traceConsole.css
/pentest/web/mantra/data/extensions/[email protected]/components/firebug-trace-service.js
/pentest/web/mantra/data/extensions/[email protected]/icons/default/TraceConsole.png
/pentest/web/mantra/data/extensions/[email protected]/content/firebug/traceConsole.js
/pentest/web/mantra/data/extensions/[email protected]/content/firebug/traceConsole.html
/pentest/web/mantra/data/extensions/[email protected]/content/firebug/traceLogFrame.html
/pentest/web/mantra/data/extensions/[email protected]tt.com/content/firebug/traceModule.js
/pentest/web/mantra/data/extensions/[email protected]/content/firebug/trace.js
/pentest/web/mantra/data/extensions/[email protected]/content/firebug/traceOverlay.xul
/pentest/web/mantra/data/extensions/[email protected]/content/firebug/traceConsole.xul
/pentest/fuzzers/spike/src/autom4te.cache/traces.2
/pentest/fuzzers/spike/src/autom4te.cache/traces.1
/pentest/fuzzers/spike/src/autom4te.cache/traces.0
/pentest/fuzzers/rfuzz/doc/mongrel-1.1.5/ri/MongrelDbg/begin_trace-c.yaml
/pentest/fuzzers/rfuzz/doc/mongrel-1.1.5/ri/MongrelDbg/trace-c.yaml
/pentest/fuzzers/rfuzz/doc/mongrel-1.1.5/ri/MongrelDbg/end_trace-c.yaml
/pentest/libs/libhijack/src/ptrace.c
/pentest/libs/libhijack/include/hijack_ptrace.h
/pentest/scanners/unicornscan/src/test_scripts/traceroute_fmtcat.sh
/pentest/telephony/warvox/web/config/initializers/.svn/text-base/backtrace_silencers.rb.svn-base
/pentest/telephony/warvox/web/config/initializers/backtrace_silencers.rb
you can find all "trace" phrases within everywhere else under the pentest directory..
find . -type f|perl -lne '@x=sort {$b->[0]<=>$a->[0]}[(stat($_))[7],$_],@x;splice(@x,11);print "@{$x[0]}";END{for(@x){print "@$_"}'
This is sample output - yours may be different.
4833673216 ./Downloads/gnome-2.29.20091103-x86/gnome-2.29.20091103-x86.vmdk
A different approach to the problem - maintain a small sorted list, print the largest as we go, then the top 10 at the end. I often find that the find and sort take a long time, and the large file might appear near the start of the find. By printing as we go, I get better feedback. The sort used in this will be much slower on perls older than 5.8.
find $(pwd) -maxdepth 1 -name "*" -printf "%p\n"
This is sample output - yours may be different.
find `pwd` -type f \( -iname thumb.php -or -iname timthumb.php \) -exec grep -HP 'define ?\(.VERSION' {} \;
This is sample output - yours may be different.
[email protected] [/home/user/public_html]# find `pwd` -type f \( -iname thumb.php -or -iname timthumb.php \) -exec grep -HP 'define ?\(.VERSION' {} \;
/home/user/public_html/domain1/wp-content/themes/arras/library/timthumb.php:define ('VERSION', '1.12'); // version number (to force a cache refresh
/home/user/public_html/domain/wp-content/themes/arras/library/timthumb.php:define ('VERSION', '1.12'); // version number (to force a cache refresh
Good for finding outdated timthumb.php scripts which need to be updated, anything over 2.0 should be secure, below that timthimb is vulnerable and can be used to compromise your website.
find `pwd` -maxdepth 1 -exec ls --color -d {} \;
This is sample output - yours may be different.
find -iname "*.pdf" -exec pdfinfo -meta {} \;|awk '{if($1=="Pages:"){s+=$2}}END{print s}'
This is sample output - yours may be different.
This sums up the page count of multiple pdf files without the useless use of grep and sed which other commandlinefus use.
mplayer -endpos 0.1 -vo null -ao null -identify *.avi 2>&1 |grep ID_LENGTH |cut -d = -f 2|awk '{SUM += $1} END { printf "%d:%d:%d\n",SUM/3600,SUM%3600/60,SUM%60}'
This is sample output - yours may be different.
Better awk example, using only mplayer, grep, cut, and awk.
find /usr/include/ -name '*.[c|h]pp' -o -name '*.[ch]' -print0 | xargs -0 wc -l | tail -1
This is sample output - yours may be different.
find /usr/include/ -name '*.[c|h]pp' -o -name '*.[ch]' -exec cat {} \;|wc -l
This is sample output - yours may be different.
Count your source and header file's line numbers
For example for java change the command like this
find . -name '*.java' -exec cat {} \;|wc -l
find . -type f -exec awk '/linux/ { printf "%s %s: %s\n",FILENAME,NR,$0; }' {} \;
This is sample output - yours may be different.
find `pwd` -name '.*' -prune -o \( -name *.h -o -name *.cpp \) -print | cscope -bi-
This is sample output - yours may be different.
cd /
find `pwd` -name '.*' -prune -o \( -name *.h -o -name *.cpp \) -print | cscope -bi-
export CSCOPE_DB=/cscope.out
vim +'set cst'
find . ! -name "$(printf '*[\001-\037\177]*')"
This is sample output - yours may be different.
This is sample output - yours may be different.
./CustomFields/add-avatars.php
./examples/example-widget.php
./examples/multiwidget.php
./examples/Recent_Comments.php
./examples/Recent_Posts.php
needs grep what supports '--recursive'
for i in /usr/bin/* ;do touch ${i##*/}; done
This is sample output - yours may be different.
You could avoid xargs and sed in this case (shorter command and less forking): At least bash and zsh have some mighty string modifiers.
I would also suggest using find with exec option to get more flexibility. You may leave out or include "special" file for example.
alias busy='rnd_file=$(find /usr/include -type f -size +5k | sort -R | head -n 1) && vim +$((RANDOM%$(wc -l $rnd_file | cut -f1 -d" "))) $rnd_file'
This is sample output - yours may be different.
Enhancement for the 'busy' command originally posted by busybee : less chars, no escape issue, and most important it exclude small files ( opening a 5 lines file isn't that persuasive I think ;) )
This makes an alias for a command named 'busy'. The 'busy' command opens a random file in /usr/include to a random line with vim.
#!/bin/bash find | grep -P -v "(class)|(zip)|(png)|(gz)|(gif)|(jpeg)|(jpg)" | xargs -I @ grep -H $1 @
This is sample output - yours may be different.
./Main.java:// public static void main(String[] args) throws IOException
calls grep on all non-binary files returned by find on its current working directory
find . -type f -name '*.jpg' -exec convert -quality 75 {} {} \;
This is sample output - yours may be different.
find /path/folder -type f -name "*.*" -print -exec rm -v {} + | wc -l;
This is sample output - yours may be different.
It does not work without the verbose mode (-v is important)
ls -trF | grep -v \/ | tail -n 1
This is sample output - yours may be different.
$ ls -trF | grep -v \/ | tail -n 1
ramonroche.sh*
Sort by time and Reverse to get Ascending order, then display a marker next to the a file, negate directory and select only 1 result
sudo find / -type f | perl -MFile::Basename -ne '$counts{dirname($_)}++; END { foreach $d (sort keys %counts) {printf("%d\t%s\n",$counts{$d},$d);} }'|sort -rn | tee /tmp/sortedfilecount.out | head
This is sample output - yours may be different.
2958 /var/www/vhosts/example.com/dir1
2259 /usr/share/man/man3
1283 /var/www/vhosts/example.com/dir2
1124 /usr/share/man/man3p
1091 /usr/share/man/man1
861 /var/www/vhosts/example.com/dir3
763 /usr/bin
717 /var/www/vhosts/example.com/dir4
Find which directories on your system contain a lot of files.
Edit: much shorter and betterer with -n switch.
fn=$(find . -type f -printf "%
[email protected]\t%p\n"|sort -n|tail -1|cut -f2); echo $(date -r "$fn") "$fn"
This is sample output - yours may be different.
find . -printf "%
[email protected] %p\n" | sed -e 1d | while read ts fn; do ts=${ts%.*}; if [ $ts -ge ${gts:-0} ]; then gts=$ts; echo `date -d @$gts` $fn; fi; done
This is sample output - yours may be different.