How to get a size file in Bash

03 Nov 2013 » {[{categoryPostCurrent}]}

The trick consist to use the stat -c%s myfilenamecommand.

Hereunder[^1] is a bash script that perform the job:

    #!/bin/bash
    if [ $# -eq 2 ]; then
        echo "usage: $0 filename"
    else
        FILENAME=$1
        FILESIZE=$(stat -c%s "$FILENAME")
        echo "Size of $FILENAME = $FILESIZE bytes."
    fi

[^1]: Est dignitati ille publicae tributus tot hac eadem est tot quod cum et maxime Ergo.

Voir aussi...

comments powered by Disqus