Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

curiosity in df command and pipe

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL

# for i in 1 2 3 4 5;do df -sk /home ; df -sk | grep -w /home$;echo "";done
Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 4587520 483180 90% 4171 4% /home
/dev/hd1 4587520 1920412 59% 4081 1% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 4587520 483180 90% 4171 4% /home
/dev/hd1 4587520 1920412 59% 4081 1% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 4587520 483180 90% 4171 4% /home
/dev/hd1 4587520 1920412 59% 4081 1% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 4587520 483180 90% 4171 4% /home
/dev/hd1 4587520 1920412 59% 4081 1% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 4587520 483180 90% 4171 4% /home
/dev/hd1 4587520 1920412 59% 4081 1% /home


Anyone know the explaination?
 
ogniemi,

What do you really wants to be explained?

if you separate the for loop like that then you will see how this was translated into the output you've got

Code:
for i in 1 2 3 4 5;
do 
df -sk /home;
df -sk | grep -w /home$;
echo "";
done

so that's why you are getting two lines for /home!
one for df -sk /home;
and the other for df -sk | grep -w /home$;

is that what you want?

Regards,
Khalid
 
please compare these two lines - one got with "df -sk /home" and the other with "df -sk | grep -w /home$"

two lines linked to the same filesystem /home but different Free, %Usage, Iused, $Iused

That was my question, why lines are different...
 
hmmmm

Interesting!!!

I ran the same command on my machine and this is the output i got:

Code:
# for i in 1 2 3 4 5;do df -sk /home ; df -sk | grep -w /home$;echo "";done
Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    260368    1%      166     1% /home
/dev/hd1           262144    260368    1%      166     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    260368    1%      166     1% /home
/dev/hd1           262144    260368    1%      166     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    260368    1%      166     1% /home
/dev/hd1           262144    260368    1%      166     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    260368    1%      166     1% /home
/dev/hd1           262144    260368    1%      166     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    260368    1%      166     1% /home
/dev/hd1           262144    260368    1%      166     1% /home

????

so its exactly the same!!!

Regards,
Khalid
 
I run on two different my systems and the output is not the same


# for i in 1 2 3 4 5;do df -sk /home ; df -sk | grep -w /home$;echo "";done
Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 393216 288200 27% 1815 3% /home
/dev/hd1 393216 288588 27% 1815 3% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 393216 288200 27% 1815 3% /home
/dev/hd1 393216 288588 27% 1815 3% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 393216 288200 27% 1815 3% /home
/dev/hd1 393216 288588 27% 1815 3% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 393216 288200 27% 1815 3% /home
/dev/hd1 393216 288588 27% 1815 3% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 393216 288200 27% 1815 3% /home
/dev/hd1 393216 288588 27% 1815 3% /home


# for i in 1 2 3 4 5;do df -sk /home ; df -sk | grep -w /home$;echo "";done
Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 524288 301596 43% 2567 4% /home
/dev/hd1 524288 301448 43% 2606 4% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 524288 301596 43% 2567 4% /home
/dev/hd1 524288 301448 43% 2606 4% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 524288 301596 43% 2567 4% /home
/dev/hd1 524288 301448 43% 2606 4% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 524288 301596 43% 2567 4% /home
/dev/hd1 524288 301448 43% 2606 4% /home

Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd1 524288 301596 43% 2567 4% /home
/dev/hd1 524288 301448 43% 2606 4% /home


can you try on other hosts?
 


Code:
# for i in 1 2 3 4 5;do df -sk /home ; df -sk | grep -w /home$;echo "";done
Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    261760    1%        5     1% /home
/dev/hd1           262144    261760    1%        5     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    261760    1%        5     1% /home
/dev/hd1           262144    261760    1%        5     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    261760    1%        5     1% /home
/dev/hd1           262144    261760    1%        5     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    261760    1%        5     1% /home
/dev/hd1           262144    261760    1%        5     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    261760    1%        5     1% /home
/dev/hd1           262144    261760    1%        5     1% /home

Code:
# for i in 1 2 3 4 5;do df -sk /home ; df -sk | grep -w /home$;echo "";done
Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    261760    1%        5     1% /home
/dev/hd1           262144    261724    1%       11     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    261760    1%        5     1% /home
/dev/hd1           262144    261724    1%       11     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    261760    1%        5     1% /home
/dev/hd1           262144    261724    1%       11     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    261760    1%        5     1% /home
/dev/hd1           262144    261724    1%       11     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           262144    261760    1%        5     1% /home
/dev/hd1           262144    261724    1%       11     1% /home

oh yeah that was different!!!

Code:
# for i in 1 2 3 4 5;do df -sk /home ; df -sk | grep -w /home$;echo "";done
Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           131072    130708    1%        5     1% /home
/dev/hd1           131072    130708    1%        5     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           131072    130708    1%        5     1% /home
/dev/hd1           131072    130708    1%        5     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           131072    130708    1%        5     1% /home
/dev/hd1           131072    130708    1%        5     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           131072    130708    1%        5     1% /home
/dev/hd1           131072    130708    1%        5     1% /home

Filesystem    1024-blocks     Free* %Used    Iused %Iused Mounted on
/dev/hd1           131072    130708    1%        5     1% /home
/dev/hd1           131072    130708    1%        5     1% /home

hmmmmmm

its getting more interesting :)
 
I believe the first df -sk /home is looking into whatever inside the home directory but df -sk | grep -w /home is including /home with it!!! so that explains the Iused and %Iused differences???!!!

:)
 
FYI
on my AIX 5.2

df -sk /usr
Filesystem 1024-blocks Free* %Used Iused %Iused Mounted on
/dev/hd2 6689789819698944 0 100% 4096 100% /usr

df -sk | grep usr
/dev/hd2 3145728 1557588 51% 32402 5% /usr

WOW! 100% used
 
on my side I'd observed it on

# oslevel -s
5200-08-01

# oslevel -s
5300-04-01


 
Hi

In documentations it says:
-s Gets file system statistics from the VFS specific file system helper instead of the statfs system call. Any arguments given when using the -s flag must be a JFS or Enhanced JFS filesystem mount point or device. The filesystem must also be listed in /etc/filesystems.

But it does not explain why the differance, but the information is collected with different methods :-(

Could it be odm problem, what happend if synclvodm is issued ?

/HGA
 
On the other hand I can't reproduce it on my AIX 5.1 systems. Does it make any difference if you use 'df -k' as opposed to 'df -sk'?

Ceci n'est pas une signature
Columb Healy
 
AIX 5.2

df -k is OK
it is definately the -s option that screws it up
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top