- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ls (is the result in bytes)
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2009 10:00 AM
тАО02-26-2009 10:00 AM
i would like to know what is the size of the result after i run the command "ls -l"
Example:
$ ls -lrt prueba
-rw-rw-r-- 1 ftphr sapsys2 21 Feb 26 12:58 prueba
is "21" in bytes? if so, how can i run ls to get the value in Mb?
please let me know.
Thanks.
Dma.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2009 10:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2009 10:14 AM
тАО02-26-2009 10:14 AM
Re: ls (is the result in bytes)
Of course.
If you want it in Mb, you will have to write a script:
ll -rt prueba | awk '
NF >= 9 {
print $1, $2, $3, $4, $5/(1024*1024), $6, $7, $8, $9, $10, $11
next
}
{
print $0
}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2009 10:55 AM
тАО02-26-2009 10:55 AM
Re: ls (is the result in bytes)
only 1 time: 1024?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2009 10:59 AM
тАО02-26-2009 10:59 AM
Re: ls (is the result in bytes)
> and , what about Kb? how can i do that?
Yes:
# ls -l | awk '{$5=sprintf("%6.2f",$5/1024);print}'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 01:34 PM
тАО03-05-2009 01:34 PM
Re: ls (is the result in bytes)
when i run:
ls -l | awk '{$5=sprintf("%6.2f",$5);print}'
the result is:
how can i gent 27.00 ?
total 32 0.00
-rw-rw-r-- 1 ftphr sapsys2 20.00 Mar 5 16:33 file1
-rw-rw-r-- 1 ftphr sapsys2 7.00 Mar 5 16:33 file2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 01:40 PM
тАО03-05-2009 01:40 PM
Re: ls (is the result in bytes)
Yes, we should skip the "total" line at the head of the list:
# ls -l | awk '/^total/ {print;next};{$5=sprintf("%6.2f",$5/1024);print}'
...converts to KB...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 01:43 PM
тАО03-05-2009 01:43 PM
Re: ls (is the result in bytes)
I have a question, if i run:
$ ls -lR | awk '{ sum += $5 } END { print sum }'
I got:
1.26335e+08
if i run:
$ ls -l | awk '/^total/ {print;next};{$5=sprintf("%6.2f",$5/1024);print}'
I got: total 155152 (KB)
is the same both cases? i mean, the result (numbers) are different .... how can i explain that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 01:52 PM
тАО03-05-2009 01:52 PM
Re: ls (is the result in bytes)
ls -lR | awk '{ sum += $5 } END { print sum }'
example two had:
ls -l | awk '/^total/ {print;next};{$5=sprintf("%6.2f",$5/1024);print}'
the "-R" in example one caused it to list the sizes of all the files in all the subdirectories, while the second didn't have that option.
also notice that the second example got rid of the "total" line, although this should not change the results.
Basically, you appear to have run the test with different sets of data!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 02:00 PM
тАО03-05-2009 02:00 PM
Re: ls (is the result in bytes)
example one totals the sizes of all the files in the list, as in:
ls -lR | awk '{ sum += $5 } END { print sum }'
5912633
example two converts / displays each file to KB and displays that in the list:
ls -l | awk '/^total/ {print;next};{$5=sprintf("%6.2f",$5/1024);print}'
total 668
-rwxr----- 1 root root 0.00 Feb 23 12:26 abc
-rw-r--r-- 1 root root 1.73 Dec 26 16:05 add.hosts
-rw-r--r-- 1 root root 1.72 Dec 26 19:50 anaconda-ks.cfg
drwxr-xr-x 2 root root 4.00 Feb 25 10:26 c2
drwx------ 3 root root 4.00 Dec 26 19:57 Desktop
-rw-r--r-- 1 root root 120.00 Dec 30 14:07 examples.tar
-rwxr-xr-x 1 root root 0.04 Feb 27 15:18 fsm
-rw-r--r-- 1 root root 0.10 Mar 2 15:54 fsm1
-rwxr-xr-x 1 root root 0.13 Mar 2 16:11 fsm1.sh
-rw-r--r-- 1 root root 0.10 Mar 2 14:45 fsm2
-rw-r--r-- 1 root root 0.03 Feb 5 15:27 fsma1
-rw-r--r-- 1 root root 0.52 Feb 5 15:25 fsmawk
-rwxr-xr-x 1 root root 0.16 Feb 19 16:27 fsm.sh
-rw-r--r-- 1 root root 46.62 Dec 26 19:50 install.log
-rw-r--r-- 1 root root 5.10 Dec 26 19:50 install.log.syslog
drwxr-xr-x 3 root root 4.00 Jan 9 10:34 sudo
-rw-r--r-- 1 root root 423.72 Dec 26 15:28 tzdata-2008i-1.el2_1.noarch.rpm