LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   one query (https://www.linuxquestions.org/questions/linux-newbie-8/one-query-833472/)

sushil.cool 09-21-2010 12:48 AM

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

Nylex 09-21-2010 12:50 AM

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.

grail 09-21-2010 12:57 AM

Looks like homework to me??

prayag_pjs 09-21-2010 01:16 AM

du -chs *.dat

sushil.cool 09-21-2010 01:33 AM

its not working in unix.plz tell me the command which can work in unix

prayag_pjs 09-21-2010 01:54 AM

Which Unix OS you are using ?

prayag_pjs 09-21-2010 01:55 AM

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


All times are GMT -5. The time now is 10:16 PM.