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 :: bash load file as array 
Shell :: pip problem linux 
Shell :: install powershell on windows 
Shell :: Google Chrome freeze uploading a file ubuntu 22.04 
Shell :: how to install wifite for kali linux 
Shell :: install jenkins in linux 
Shell :: add extra cygwin packages 
Shell :: rm -rf * 
Shell :: git look at changes to a file 
Shell :: run docker compose 
Shell :: @react-navigation/stack install npm 
Shell :: running shell commands nodejs 
Shell :: git clone in 
Shell :: list remote branches git 
Shell :: revert last merge git 
Shell :: adb screenrecord 
Shell :: git Config User with Cli 
Shell :: open podfile in xcode from terminal 
Shell :: stop docker image 
Shell :: build cordova app command 
Shell :: how to install deb package with apt 
Shell :: docker redis 
Shell :: install cuda in ubuntu 
Shell :: git commit and add in one command 
Shell :: powershell change directory 
Shell :: como atualizar a versão do angular 
Shell :: uniq bash sort 
Shell :: update path variable mac 
Shell :: add credentials git linux 
Shell :: ERR_NO_CERTIFICATES: Encountered adb error: NoCertificates. ionic 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =