Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

get file size in bash

# du is ok but is not accurate
# This is because it returns the disk usage for the target
# rather than the actual file size of the target.

# However, you can get more accurate results using the `--apparent-size` arg

du --apparent-size -h path/to/<file|folder>

# -h is tell it to print in a human readable format
Comment

bash size file

du -hs file/or/folder/path

---------------------------------------------------
-h for human readable
-s for summary: only total amount, not single files
Comment

how to get file size of a file in bash script

#!/bin/bash
echo "Enter the full path to the file."
read file
filesize=$(ls -lh $file | awk '{print  $5}')
echo "$file has a size of $filesize"
Comment

PREVIOUS NEXT
Code Example
Shell :: change shell kali linux 
Shell :: bash convert string to uppercase 
Shell :: ubuntu terminal network monitor 
Shell :: if regex bash 
Shell :: bash check if file empty 
Shell :: powershell foreach 
Shell :: add change to your last commit 
Shell :: check ram arch linux 
Shell :: check gcc version 
Shell :: Ports are not available: listen tcp 0.0.0.0:61616: bind: An attempt was made to access a socket in a way forbidden by its access permissions. 
Shell :: heroku rebuild 
Shell :: bash shortcuts 
Shell :: restart webmin terminal 
Shell :: install neo4j latest version ubuntu 
Shell :: get request linux terminal 
Shell :: install apache benchmark 
Shell :: remove unnecessary npm packages 
Shell :: apt vs apt-get 
Shell :: merge remote commits to local then push 
Shell :: ubuntu 20.04 how to check dns server 
Shell :: install wkhtmltopdf linux command 
Shell :: linux ogg to wav 
Shell :: linux find ip of other computers on network 
Shell :: how to get updates in linux 
Shell :: enable null safety flutter using cmd 
Shell :: list all gpg keys ubuntu 
Shell :: how to upgrade in linux 
Shell :: docker compose multiple command 
Shell :: git version 
Shell :: installing sh file linux 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =