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
- using ls command (ls -s)
- using du command (du -s)
- using stat command
- 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
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.txt3. 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.txt4. 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
Comments
Post a Comment