Get size of a file using ls on all UNIX OSes

Hi Yoda...

There are definately leading spaces and could be a trailing space as well.
Also newline(s) may be part of the result...

Last login: Fri May  3 08:01:47 on ttys000
Barrys-MacBook-Pro:~ barrywalker$ wc -c < SCOPE.GIF
   17424
Barrys-MacBook-Pro:~ barrywalker$ 

EDIT:

Last login: Fri May  3 08:01:47 on ttys000
Barrys-MacBook-Pro:~ barrywalker$ wc -c < SCOPE.GIF
   17424
Barrys-MacBook-Pro:~ barrywalker$ wc -c < SCOPE.GIF > length.txt
Barrys-MacBook-Pro:~ barrywalker$ ls -l len*
-rw-r--r--  1 barrywalker  staff  9  3 May 08:15 length.txt
Barrys-MacBook-Pro:~ barrywalker$ hexdump -C length.txt
00000000  20 20 20 31 37 34 32 34  0a                       |   17424.|
00000009
Barrys-MacBook-Pro:~ barrywalker$ 

There as a proof test...

1 Like

thank you!!!!

ls -lo seems to be perfect. not sure if it'll work on every UNIX hosts though. so far, i tested it on linux/sunos and it has the size of the file in the 4th column on both OSes. thank you!