Tip #171 Duplicate directory tree
The following command creates in the /usr/project directory, a copy of the current working directory structure:Read more »
Tip #363 Finding log files X number of days old and deleteing them.
This is a script that I recently wrote to find the logs of my IDP that were over 90 days old and delete them.The script is pretty much self explanatory.
Read more »
Tip #307 Delete old files
Use find by time to delete files more than x days old. For example the command below will delete files more than one day old:find . -mtime +1 -exec rm {} \; Read more »
Tip #796 Find files by mime-type
Use this command to find files of a given mime-type. For example to find all PNG images in a directory or below:Read more »
- TAGS:
- find
Tip #165 Directories and its size
which directories and trees take up all the diskspace?du -sm $(find /start/dir/* -type d -maxdepth 1 -xdev) | sort -g
If you want more human readable output try:
du -ha /var | sort -n -r | head -n 10
you want to see ALL directories in the tree
find $1 -type d | xargs du -sm | sort -g
To show all directories size including sub directories, type
du -h
To calculate the current directory size you are in (-s stand for summary)
du -sh
To show all the 1 level sub directories size (which you are not interested at sub sub directories.)
du -sh *
To show the size of specific directory
du -sh /home
To show the size of all sub directories of a specific directory
du -sh /home/* Read more »
Tip #850 Checksum directory recursively
Do a sha256sum of an entire directory name directory and check for integrity.Modifying the IFS variable is necessary for filename with space.
Read more »
Tip #231 Rename many files using find and perl
Rename a lot of files at once: Read more »Tip #208 Pipe files to an archive
If you want to select specifically the files to add to an archive you can pipe the output from find (or any command that gives a list of files) to cpio:Read more »
alias aptitude at awk bash bc cal cat cd colrm comm cp csh curl cut date dd df dialog diff dirname dpkg du fc find fuser grep gs gzip history iconv kill ksh last less ln ls lsof lynx m4 md5sum mkdir mkfifo mkisofs mv mysql nc netstat openssl OSX perl ping popd ps pushd python read redirection rm scp screen sed sort ssh stat sudo svn tail tar tee test top tr uniq vim wc wget xargs