LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-07-2017, 07:31 AM   #1
sysdljr
LQ Newbie
 
Registered: Feb 2017
Posts: 2

Rep: Reputation: Disabled
why du -sh is not correct ?


HI,
I am testing LZ4 compress command in shell script.
after compress finished, run du -sh view filesize , result more than true value, but run ls -l result is normal.

filepath=/home/test.lz4
filesize=$(ls -l $filepath | awk '{print $5}')
filesize=$(du -sh $filepath | awk '{print $1}'
 
Old 02-07-2017, 07:56 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,210

Rep: Reputation: 1389Reputation: 1389Reputation: 1389Reputation: 1389Reputation: 1389Reputation: 1389Reputation: 1389Reputation: 1389Reputation: 1389Reputation: 1389
These are NOT the same thing.

Go read the man page on du.

Hint: Go read up on --apparent-size

du gives the disk usage size based on the block size (if your file has even 1 byte in a block then the whole block is considered used).
ls gives the file size.
 
Old 02-09-2017, 06:39 AM   #3
sysdljr
LQ Newbie
 
Registered: Feb 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thank you very much.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
does this seem correct to you? sigint-ninja Linux - Newbie 4 08-31-2016 02:26 PM
How do I correct this? Spartacus2013 Linux - Newbie 5 03-25-2013 08:42 PM
Rows in lists on my Debian are correct/black/correct/black... eikhorsholm Linux - Desktop 1 10-01-2009 05:24 PM
Is this correct? cornbeef Slackware 1 01-24-2006 12:31 AM
Am I correct? equinox Mandriva 6 03-11-2004 05:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration