The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 01-02-2008
Amey Joshi Amey Joshi is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 50
Post some query in awk

Hi ,
I want to assign a value to variable which will have size of the file that is
we have following files for eg:
ls -ltr
-rw-rw-r-- 1 dsadmin dstage 34 Oct 29 12:14 some.txt
-rw-rw-r-- 1 dsadmin dstage 0 Oct 29 14:52 eg.txt
-rwxrwxr-x 1 dsadmin dstage 1453 Oct 30 08:07 time1.sh
-rw-rw-r-- 1 dsadmin dstage 197 Oct 30 08:13 start.txt
-rwxrwxr-x 1 dsadmin dstage 1389 Oct 30 09:26 time.sh
-rwxrwxr-x 1 dsadmin dstage 311 Nov 12 15:23 timeone.sh
-rwxrwxr-x 1 dsadmin dstage 123 Nov 26 09:48 som1.sh

sizes are marked in bold.Now if i use the following command
size=`ls -ltr | awk '{printf $5}'`
it is giving me out put as
size=34014531971389311123
But my requirement is
size=34
size=0 and so on...

Can anybody help me out since i am new to unix..
Thanks in Advance