Advanced bash scripting

Bash Commands

Finding a size of a file

file_size=$(stat -c%s "$FILENAME")

Wait for user to strike a key

read -p "Press [Enter] key to start backup..."

Filename from Filepath

Extracting File Name with extension and without extension given full file path

filewithpath=/home/name/path/subpath/etc/abc.txt
filename=$(basename $filewithpath)
filenoext=${filename%%.*}

filename will have abc.txt

filenoext will have abc


QR Code
QR Code tech:linux:bash_commands (generated for current page)