But it can be used to display total hard disk size. The wc command shows the number of lines, words, and bytes contained in file. That’s the size of space on the disk that is used to store the meta-information for the directory, not what it contains. If any of these exist, the block size is set, and du stops checking. You can easily extract the first field either using the cut or awk command: wc -c /etc/passwd | awk '{print $1}' Sample outputs: 5253. 2.8G ostechnix 279G /home/sk/ 281G total. ls -l /bin/grep. Unless, that is, an environment variable called POSIXLY_CORRECT is set. If none are set, du defaults to a block size of 1,024 bytes.

You must type the following command as the root user: # fdisk -l | grep Disk. To display only the grand total of the given directory including all the sub-directories, use ‘grep’ command with ‘du’ command like below. target — mount point of a drive . Sample outputs: -rwxr-xr-x 1 root root 175488 May 13 2012 /bin/grep.

OR assign this size to … If that’s the case, du defaults to a block size of 512 bytes. The syntax is as follows to get the file size: wc -c /path/to/file wc -c /etc/passwd Sample outputs: 5253 /etc/passwd. ADVERTISEMENTS. used — spaced used on a drive. $ du -ch Downloads/ | grep total 12G total. pcent — percent of used space, divided by total size. You might want to exclude certain type of files. avail — space available on a drive. For a more user friendly output, pass the -h option to the ls command: ls -lh / bin /grep.

size — total number of blocks. When listing the contents of a directory using the ls command, you may have noticed that the size of the directories is almost always 4096 bytes (4 KB). In the above output example, the 175488 is the size of the file. How to check file size in unix using wc command. The fdisk command is partition table manipulator for Linux. The command for this would be: Let’s display the output of all our drives, showing only the size, used, and avail (or availability) fields. Sample outputs: Disk /dev/hda: 20.0 GB, 20060651520 bytes Disk /dev/hdb: 80.0 GB, 80060424192 bytes.