Useful ussage of find and du commands

Useful ussage of find and du commands

find

$ find /home/zuko -type f -size 875c
$ find /home/zuko -name '*.mp3' -size -5000k
$ find /home/zuko -size +10000k
$ find /home/zuko -name '*.cpp' -exec more {} \; | grep MyText
$ find /home/zuko -name '*.cpp' -exec sh -c 'more $1 | grep MyText' {} {} \;
$ find /home/zuko -name '*.tmp' -exec rm {} \;
$ find /home/zuko -name "*.[ch]*" | xargs grep -c "^[ \t]*#include" | sort -rn -t : +1 -2 | more

(1) find all files with size equal to 875 bytes in /home/zuko directory
(2) find all ‘*.mp3’ files that have a size less than 5000 Kilobytes ( 10MB)
(4) grep all *.cpp files in /home/zuko directory for looking string MyText
(5) alternative of (4)
(6) find all *.tmp files and delete it
(7) count number of includes in *.c and *h files in /home/zuko directory

du

$ du -sh

Command will show size of the current directory

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s