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



PhoebeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.