• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

Size of a gruop of files

Hi, experts

I just start to study Solaris 2.6 . Did anyone knows how to find
size of a gruop of files , Say

ls -l a*

how can find the total size of the group file a*.

Is it possible I can find out the available size of free disk


Thanx in advance



0
Phoebe
Asked:
Phoebe
1 Solution
 
n0thingCommented:
ls -l a* | du
and
df -k
to see the available free disk space on your system.
0
 
blowfishCommented:
*****

ls -l a* | du

is a wrong answer .....

this creates a long directory listing that includes; permissions, owner, group, size, date, and filename, and then pipes all the text to du.  

*****

to find the total size of a group of files;

  du -k a* | awk '{s+=$1} END {print "total size is:" s}'

to find the amount of free disk space;

  df -k

Hope that this helps,

--frankf

0
 
ozoCommented:
n0thing probably meant to say ls -1
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
blowfishCommented:
yes, of course n0thing meant to say ls -1, I realized that when I first posted my comments.  However, I was too lazy to type in the following explanation;

Piping the output from ls into du dosen't cause du to calculate the space utilization correctly.  You must get du to calculate the size based on what it sees in your directory.  

For example, here is a directory listing of /etc/inet, taken from a system running Solaris 2.6;

-r--r--r--   1 root     sys          180 Sep 30 10:45 hosts
-r--r--r--   1 root     sys         5632 Jul 21  1998 inetd.conf
-r--r--r--   1 root     sys          595 Jun 25  1998 netmasks
-r--r--r--   1 root     sys          372 Jun 25  1998 networks
-rw-r--r--   1 root     other        436 May 13  1998 ntp.conf.client
-rw-r--r--   1 root     other       3505 May 13  1998 ntp.conf.server
-rw-r--r--   1 root     other          7 Apr 23  1998 ntp.drift
-rw-r--r--   1 root     other          0 Apr 17  1998 ntp.keys
-r--r--r--   1 root     sys          980 Jun 25  1998 protocols
-r--r--r--   1 root     sys         2177 Jun 25  1998 services
-r--r--r--   1 root     sys          305 Jun 25  1998 sock2path

Running ls -1 | du -k, gives us the following, correct total;

  21      .

but, Running ls -1 a* | du -k, gives this ..

  ls -1 a* | du -k
  a*: No such file or directory
  21      .

Running ls on a set of files that do exist, gives this output, which is not the correct total ..

  ls -1 ntp* | du -k  
  21      .

If we insist on piping the output of ls to du, then this way works, sort of ..

  ls -1 ntp* | xargs du -k
  1       ntp.conf.client
  4       ntp.conf.server
  1       ntp.drift
  0       ntp.keys
 
But it didn't calculate the total space used, which is why I posted my version.  

Regards to all who have commented,

--frankf
0
 
PhoebeAuthor Commented:
This should be for blowfish
0
 
PhoebeAuthor Commented:
This should be for blowfish
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now