I need to check the display the files
my server with their sizes.Which command that I need to use.
Any variants of ls
command?
don't worry we have a got a UNIX command to do that for you and command is "df" which displays the size of the file system in UNIX. You can run "df" UNIX command with the current directory or any specified directory.
Using the ls Command –l – displays a list of files and directories in long format and shows the sizes in bytes. –h – scales file sizes and directory sizes into KB, MB, GB, or TB when the file or directory size is larger than 1024 bytes. –s – displays a list of the files and directories and shows the sizes in blocks.
Locate the file or folder whose size you would like to view. Click the file or folder. Press Command + I on your keyboard. A window opens and shows the size of the file or folder.
How to check file size in unix using wc command. The wc command shows the number of lines, words, and bytes contained in file. The syntax is as follows to get the file size: wc -c /path/to/file. wc -c /etc/passwd. Sample outputs:
I am a new bash shell scripting user. How do I find out the size of a file in my bash shell script and store this file size in a bash shell variable? You can not get the size of a file in a bash script using an internal or built-in command. It would be best to use the stat and other commands under Linux to check the file size.
Two measurements are used in relation to file size. The first is the actual size of the file, which is the number of bytes of content that make up the file. The second is the effective size of the file on the hard disk. This is the number of file system blocks necessary to store that file.
A file doesn’t include only text files, images, and compiled programs but also includes partitions, hardware device drivers, and directories. The following Linux commands can be used to check file size.
I hope ls -lah
will do the job. Also if you are new to unix environment please go to http://www.tutorialspoint.com/unix/unix-useful-commands.htm
stat -c %s file.txt
This command will give you the size of the file in bytes. You can learn more about why you should avoid parsing output of ls command over here: http://mywiki.wooledge.org/ParsingLs
ls -l --block-size=M
will give you a long format listing (needed to actually see the file size) and round file sizes up to the nearest MiB. If you want MB (10^6 bytes) rather than MiB (2^20 bytes) units, use --block-size=MB instead.
Or
ls -lah
-h When used with the -l option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the number of digits to three or less using base 2 for sizes.
man ls
http://unixhelp.ed.ac.uk/CGI/man-cgi?ls
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With