Bash – Rozmiar pliku

Dzisiaj potrzebowałem pobrać rozmiar pliku poprzez konsolę. Przeglądając fora, natknąłem się na kilka ciekawych sposobów:

stat -c%s filename
ls -l filename |awk -F” “‘{ print $5 }’
du -h filename
du -b filename | sed ‘s/\([0-9]*\)\(.*\)/\1/’
cat filename | wc -c
ls -l filename | cut -d ” ” -f 5

Z tego wszystkiego, najodpowiedniejszym rozwiązaniem wydaje się stat bądź du.
Reszta jest pokazana raczej jako ciekawostki.

No comments yet

Dodaj komentarz

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Zmień )

Twitter picture

You are commenting using your Twitter account. Log Out / Zmień )

Facebook photo

You are commenting using your Facebook account. Log Out / Zmień )

Connecting to %s

Follow

Otrzymuj każdy nowy wpis na swoją skrzynkę e-mail.