Tag Info

New answers tagged

2

awk can do that all alone: df -B KB | awk 'NR!=1&&$1!~/tmpfs|cdrom/{printf "'$(date "+%Y-%m-%d-%H:%M:%S")','$(hostname)',%s,%s,%s,%s\n", $2, $3, $4, $1}' Explanation: df -B KB: prints the values in KB awk NR!=1: avoid the first line $1!~/tmpfs|cdrom/: if the first field contains not the excluded filsystems printf: print formatted $(date ...


1

Try something like this: find . -type f | perl -aF/ -lne 'for (my $i=0; $i < @F-1; ++$i) { print join("/",@F[0...$i]); }' | sort | uniq -c find . -type f prints files: ./dir1/subdir2/file8 ./dir1/subdir2/file7 ./dir1/subdir2/subdir3/file9 ./dir1/subdir2/file6 ./dir1/file1 ... perl -aF/ -lne 'for (my $i=0; $i < @F-1; ++$i) { print ...


1

Based on my comment, a variation on this might do what you want: find . -depth -type d -exec /bin/sh -c 'printf "%5d %s\n" "$(find {} -type f -printf . | wc -c)" "{}"' \; (which the doing it properly brigade will surely, and rightfully, shoot me for for calculating the result for deeper subdirectories several times and hoping the filesystem cache has the ...


1

If you have find (which can be used to iterate through all files in a directory, including all files in subdirectories of the directory) and wc (which counts the number of lines in a file) then how about the one-liner find <directory> | wc where <directory> is the directory you want to count all the files in. This prints out three numbers; the ...


0

With zsh: print -rl -- **/*.(rar|zip)(DoL) Replace with ls -lUd -- if you want to see ls -l information about them (-U being a GNU extension). Note that it sorts by size, not disk usage.


1

The possible duplicate Link answered the question partly. To provide multiple name patterns to 'find' use this find $directory -type f \( -name "*.zip" -o -name "*.rar" \) The complete answer to the question is: find $directory -type f \( -name "*.zip" -o -name "*.rar" \) -print0 | xargs -0 -n1 du -b | sort -n -r with $directory being comp_tuts/ dir


8

This is because files use up space in whole-block increments. So if your block size is 512 bytes and you have a small 100 byte file, the size it actually uses up will be rounded up to the nearest block - in this case 512. When tarring, because the result is a single file, that inefficiency is reduced since there is only one resultant file - the .tar file. ...


2

What did you delete? If you remove a file that is still in use by a running process (e.g., a daemon), that disk space is only released when the process is shut down/restarted. For example, if you removed current Apache log files, the space will still be in use until you restart Apache. Similarly for system logs (those in /var/log). You can either: ...


2

Most probably you have hidden files in the folder. The point is that glob * selects only files and folders that do not start with .. So, if they do they are not passed to du command. On the other hand from top directory you get size of the directory as a whole, including dot files. To match all files in given folder, including hidden ones try (with bash) ...


0

Run the following: lsof -s | sort -nrk 7 | head You'll see output like so: firefox 2997 j 52rr REG 252,0 10485760 5505182 /some/path firefox 2997 j 50rr REG 252,0 10485760 5505182 /some/path firefox 2997 j 3rr REG 252,0 ...


3

With GNU coreutils (Linux, Cygwin) since version 8.22, you can use du --inodes, as pointed out by lcd047. If you don't have recent GNU coreutils, and there are no hard links in the tree or you don't care if they're counted once per link, you can get the same numbers by filtering the output of find. If you want the equivalent of du -s, i.e. only toplevel ...


-1

I read the rules and it does seem to indicate open ended questions like this are not encouraged. Here is a quick link to them: http://unix.stackexchange.com/help However in case it is allowed, I would suggest reading Linux CompTIA or any of the very popular certification courseware. You will need more than just the understanding of disks to become ...


1

cp -al usr link creates a bunch of hard links, but it also creates some directories. Directories can't be hard linkedĀ¹, so they're copied. Each hard link occupies the space of a directory entry, which needs to store at least the file's name and the inode number. Each directory occupies the space of a directory entry, plus an inode for its meta data. Most ...



Top 50 recent answers are included