Tip #209 Directory Tree
The following alias will print the directory structure from the current directory in tree format.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 »
Tip #199 Find files by modified time
When specifying time with find options such as -mmin (minutes) or -mtime (24 hour periods, starting from now), you can specify a number n to mean exactly n, -n to mean less than n, and +n to mean more than n. 2 For example:Read more »
- TAGS:
- find
Tip #190 dos2unix all files in a directory
dos2unix requires the name of an input and output file so it can be hard to run on a list of files. The following gets around this and will run dos2unix on all files in a directory:Read more »
- TAGS:
- find
Tip #181 Remove empty directories
To remove empty directories (even if filenames or dirnames contain spaces or weird characters) from a tree you can do:Read more »
Tip #173 Count files by type
To find out the number of files of each type in your current directory try the following:Read more »
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 #171 Duplicate directory tree
The following command creates in the /usr/project directory, a copy of the current working directory structure:Read more »
Tip #147 Find and Grep
Find all files with given name (you can use Bash expansion if you'd like), and Grep for a phrase: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