|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
What does total no. of files in ls -lrt o/p means?
when we fire ls -lrt command we see o/p as Code:
total 16 drwx------ 9 root root 8192 May 8 2002 lost+found drwxr-xr-x 2 root root 512 Jun 14 2002 TT_DB drwxrwxr-x 2 root root 512 Jul 31 2002 mail here total no. of files is always greater than actual no. of files. can someone tell why is this. Last edited by Scrutinizer; 01-17-2013 at 05:09 AM.. Reason: quote tags => code tags |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
This is from the Linux info pages:
Quote:
Last edited by radoulov; 01-17-2013 at 05:43 AM.. |
| Sponsored Links | ||
|
|
#4
|
|||
|
|||
|
thanks a lot guys, got it that it is total no. of blocks the files occupy in that directory , i thought them to be no. of files or something used below code to find the total no. of bytes Code:
sum=0 ;
b=1;
n=`ls -lsrt | awk -F " " '{print $1}' | wc -l`
n=$(($n-$b));
echo $n;
ls -lsrt | awk -F " " '{print $1}' | tail -$n | while read x
do sum=$(($sum+$x))
done;
echo $sum;Last edited by Scott; 01-17-2013 at 06:27 AM.. Reason: Code tags, please... |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Not sure I understand what you want to achieve. The sum you output is the total sum of blocks that ls outputs anyhow. This could be done with a oneliner as well: Code:
$ ls -s1|awk 'NR==1{next} {sum+=$1} END {print sum}'If you want total bytes instead, use column 5, or, use the stat command if available on your system. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| want to concatenate multiple files based on the rest of ls -lrt | mail2sant | Shell Programming and Scripting | 5 | 09-01-2010 09:18 PM |
| Column means for multiple files | larrymuli | Shell Programming and Scripting | 3 | 01-08-2009 10:57 AM |
| grep running total/ final total across multiple files | MrAd | UNIX for Dummies Questions & Answers | 5 | 05-08-2007 01:03 PM |
|
|