title: AWK Command print size in mb,kb or gb by finding a file using ls -l
body: <p>I want to get a file size using find command along with size in kb, mb or gb with decimal point of two only.</p>
  
  <p>Desired output:</p>
  
  <pre><code>15.04 MB
  10MB
  10GB
  </code></pre>
  
  <p>I have tried below command but getting error:</p>
  
  <pre><code>find /orabackup/EXPDP/ATRUS001 -name "expdp_ATRUS001_04122017_0500.dmp" -exec ls -ltr  {} \;  | awk ' {s+=$5}' '{ split( "B KB MB GB TB PB" , v ); s=1; while( $1&gt;1024 ){ $1/=1024; s++ } printf "%.2f %s", $1, v[s] }'
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>awk: cmd. line:1: fatal: cannot open file `{ split( "B KB MB GB TB PB" , v ); s=1; while( $1&gt;1024 ){ $1/=1024; s++ } printf "%.2f %s", $1, v[s] }' for reading (No such file or directory
  </code></pre>
  
  <p>even though file is present in directory giving me above error. Thank you for your help.</p>