LinuxQuestions.org
Register a domain and help support LQ
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 09-21-2010, 01:48 AM   #1
sushil.cool
LQ Newbie
 
Registered: Mar 2010
Posts: 15

Rep: Reputation: 0
one query


hi friends i have one question
there is one folder having .dat &.txt files .i have to find the size of total .dat files in that folder .please suggest me how can i find this
 
Old 09-21-2010, 01:50 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
ls -l?

Edit: oh, you only want to look at the .dat files. In that case, you'll probably want to just get sizes and add them up. One way to do it is:

total=0
for size in `ls -l *.dat | awk '{print $5}'`; do let total=$total+$size; done
echo $total

That will give you the total size in bytes. ls -l gives you the "long listing format" for the .dat files (which includes permissions, owners, sizes, etc) and then that is passed to awk to extract the sizes (which is column 5).

In future, please use thread titles that describe your question/problem.

Last edited by Nylex; 09-21-2010 at 01:55 AM.
 
1 members found this post helpful.
Old 09-21-2010, 01:57 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,252

Rep: Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685
Looks like homework to me??
 
Old 09-21-2010, 02:16 AM   #4
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,138
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
du -chs *.dat
 
Old 09-21-2010, 02:33 AM   #5
sushil.cool
LQ Newbie
 
Registered: Mar 2010
Posts: 15

Original Poster
Rep: Reputation: 0
its not working in unix.plz tell me the command which can work in unix
 
Old 09-21-2010, 02:54 AM   #6
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,138
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
Which Unix OS you are using ?
 
Old 09-21-2010, 02:55 AM   #7
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,138
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
du (abbreviated from disk usage) is a standard Unix program used to estimate the file space usage—space used under a particular directory or files on a file system.

Refer this link

http://en.wikipedia.org/wiki/Du_%28Unix%29
 
  


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
query felix2k10 Linux - Newbie 2 09-07-2010 03:47 PM
query mbg_gayed Linux - Software 5 02-04-2009 08:19 PM
interesting MySQL query/view query :s mjh Programming 3 03-25-2008 08:30 AM
mysql use output of one query in another query secretlydead Programming 2 11-19-2007 02:25 AM
help with mysql query: return nth rows in query hawarden Programming 2 07-31-2006 07:36 PM


All times are GMT -5. The time now is 10:37 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration