4 Linux Tips to Show File Size in Linux

 4 Linux Tips to Show File Size in Linux

In this blog, you will get four different tips to get a file size in linux / unix using commands. They are

  1. using ls command (ls -s)
  2. using du command (du -s)
  3. using stat command
  4. using wc command (wc -m)

1. using ls command

  • This command is used to show the file size in KB using the option -s.
Syntax
                        ls -s <filename>
Contents of Input file msg.txt









Example:        ls -s msg.txt











2. using du command

  • Like ls command, this command is also used to show the file size in KB using the option -s.
Syntax
                        du -s <filename>
Example:        du -s msg.txt













3. using stat command

  • This command is optional for ls command
  • This is also used to display the file size 
  • Unlike ls and du command, this command will display the size in bytes.
Syntax
                        stat <filename>
Example:        stat msg.txt













4. using wc command (wc -m)

  • This command is also used to display the size of file (in bytes) using the special option -m.
Syntax
                        wc -m <filename>
Example:        wc -m msg.txt













Video Demo




Comments

Popular posts from this blog

Vivo V30 Pro 5G

Xiaomi 14 - Features, Price

Oppo F25 Pro 5G Review - Features, Price