[Ilugc] Need to calculate the file size in shell scripting

  • From: rajasuperman@xxxxxxxxx (Raja Subramanian)
  • Date: Tue Jan 5 00:15:07 2010

On Mon, Jan 4, 2010 at 11:35 PM, Balachandar <balachandarlinks@xxxxxxxxx> wrote:

? I want to get the size of a file in a variable.I want to do arithmetic
operations on that variable.I used du command.But it's output is like this
"100 ? ?1.txt".
? ?i dont want any trailing attachments.I only want the file size.Any help ??

man stat

Eg.

    $ stat -c %s /bin/bash
    797784

- Raja

Other related posts: