Operating System - HP-UX
1820485 Members
2500 Online
109624 Solutions
New Discussion юеВ

can we use the command "du" (disk usage)

 
SOLVED
Go to solution
senthil_kumar_1
Super Advisor

can we use the command "du" (disk usage)

Hi

I can use du command in linux for viewing size of the file

Ex:

1) # du -h filename

it will show the size of the file

2) # du -sh directory

It will show the size of the all files available in a directory and the size of whole directory.

but i tried this same command in HP-UX but it is not working.

what is the alternative command in HP-UX

or If it is the same command then tell me the correct syntax.

pls explain me
7 REPLIES 7
T G Manikandan
Honored Contributor

Re: can we use the command "du" (disk usage)

you can fetch the size in Kb

#du -sk filename

#du -sk directory
Solution

Re: can we use the command "du" (disk usage)

senthil,

you know I'm really tempted to NOT explain - why can't you help yourself even a little bit??? This would take 2 seconds to figure out if you simply LOOKED AT THE MAN PAGE!

On linux the -h option prints in human-readable format like (1K, 2M, 4G) - this option isn't present on the HP-UX version of the command... but we do have the "-k" option which will print out the disk allocation in KB.

So simply try:

du -k filename

or

du -sk directoryname

Be aware that du does not show you the SIZE of the file, it bshows you the DISK ALLOCATION of the file. Depedning on the size and type of file the disk allocation could be less or more than the actual file size. File sizes are displayed from "ls -l". Try the following to see this:

cd /tmp
echo a > myfile
ls -l myfile
du -k myfile

You will see that vthe size does not match disk allocation.

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Ganesan R
Honored Contributor

Re: can we use the command "du" (disk usage)

Hi,

Why don't you use du to know the size of the file when simple ll command gives the result.

ofcourse, for directory size you have to use du command.

Best wishes,

Ganesh.

Re: can we use the command "du" (disk usage)

Ganesan,

see my comment and example above about the difference between disk allocation and file size...

want to see another example? Try this:

cd /tmp
dd if=/etc/issue of=/tmp/sparse bs=2048k seek=1
ls -l sparse
du -sk sparse

hey my file is 2MB in size, but only takes up 8K on disk?

That's a sparse file... and is just one reason why you should *never* think of du as showing you the "file size"

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Ganesan R
Honored Contributor

Re: can we use the command "du" (disk usage)

Hi Duncan,

It's my typo error as careless always..(-

I mean to say that use simple ll instead of du command to know the size of the file.

>>>Why don't you use du to know the size of the file when simple ll command gives the result.<<<

It should have been,

Why do you use du to know the size of the file when simple ll command gives the result.

Again my sincere apologize for that typo mistake..
Best wishes,

Ganesh.
Dennis Handly
Acclaimed Contributor

Re: can we use the command "du" (disk usage)

You can also use "ll -e" to look at the details for sparse files.
щ╗ЮчЗГ
Valued Contributor

Re: can we use the command "du" (disk usage)


Please have a look.

http://docs.hp.com/en/B2355-90689/du.1.html

Regards!
Man's mind, once stretched by a new idea, never regains its original dimensions