syntax
find <folder> -type f -mtime +30 -print
example
find -type f -mtime +90 -print
delete all files in directory older than 90days
syntax
find <folder> -type f -mtime +30 -delete
example :
find /u02/dump -type f -mtime +90 -delete
Count files in current directory
ls | wc -l
Free space on linux
Type df -h or df -k to list free disk space:
$ df -h
OR
$ df -k
Sample Output:
Filesystem Size Used Avail Use% Mounted on /dev/sdb1 20G 9.2G 9.6G 49% / varrun 393M 144k 393M 1% /var/run varlock 393M 0 393M 0% /var/lock procbususb 393M 123k 393M 1% /proc/bus/usb udev 393M 123k 393M 1% /dev devshm 393M 0 393M 0% /dev/shm lrm 393M 35M 359M 9% /lib/modules/2.6.20-15-generic/volatile /dev/sdb5 29G 5.4G 22G 20% /media/docs /dev/sdb3 30G 5.9G 23G 21% /media/isomp3s /dev/sda1 8.5G 4.3G 4.3G 51% /media/xp1 /dev/sda2 12G 6.5G 5.2G 56% /media/xp2 /dev/sdc1 40G 3.1G 35G 9% /media/backup
df -help
[root@linux5 ~]# df --help Usage: df [OPTION]... [FILE]... Show information about the file system on which each FILE resides, or all file systems by default. Mandatory arguments to long options are mandatory for short options too. -a, --all include dummy file systems -B, --block-size=SIZE use SIZE-byte blocks -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G) -H, --si likewise, but use powers of 1000 not 1024 -i, --inodes list inode information instead of block usage -k like --block-size=1K -l, --local limit listing to local file systems --no-sync do not invoke sync before getting usage info (default) -P, --portability use the POSIX output format --sync invoke sync before getting usage info -t, --type=TYPE limit listing to file systems of type TYPE -T, --print-type print file system type -x, --exclude-type=TYPE limit listing to file systems not of type TYPE -v (ignored) --help display this help and exit --version output version information and exit SIZE may be (or may be an integer optionally followed by) one of following: kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
du command examples
du shows how much space one ore more files or directories is using.$ du -sh
103M
-s option summarize the space a directory is using and -h option provides "Human-readable" output.
To get the summary of disk usage of directory tree along with its subtrees in Megabytes (MB) only. Use the option “-mh” as follows. The “-m” flag counts the blocks in MB units and “-h” stands for human readable format.
[root@linux5]# du -mh /home/tecmint 40K /home/tecmint/downloads 4.0K /home/tecmint/.mozilla/plugins 4.0K /home/tecmint/.mozilla/extensions 12K /home/tecmint/.mozilla 12K /home/tecmint/.ssh 673M /home/tecmint/Ubuntu-12.10 674M /home/tecmint
list all file extensions in current directory
find . -type f | awk -F'.' '{print $NF}' | sort| uniq -c | sort -g
Find a file "foo.bar" that exists somewhere in the filesystem
$ find / -name foo.bar -print
Find a file, who's name ends with .bar, within the current directory and only search 2 directories deep
$ find . -name *.bar -maxdepth 2 -print
No comments :
Post a Comment