Differences
This shows you the differences between two versions of the page.
tech:linux:bash_commands [2015/06/24 06:55] |
tech:linux:bash_commands [2015/06/24 06:55] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Advanced bash scripting ====== | ||
+ | http://www.tldp.org/LDP/abs/html/index.html | ||
+ | |||
+ | ====== Bash Commands ====== | ||
+ | |||
+ | ===== Finding a size of a file ===== | ||
+ | <code bash> | ||
+ | file_size=$(stat -c%s "$FILENAME") | ||
+ | </code> | ||
+ | |||
+ | ===== Wait for user to strike a key ===== | ||
+ | <code bash> | ||
+ | read -p "Press [Enter] key to start backup..." | ||
+ | </code> | ||
+ | |||
+ | ===== Filename from Filepath ===== | ||
+ | Extracting File Name with extension and without extension given full file path | ||
+ | <code bash> | ||
+ | filewithpath=/home/name/path/subpath/etc/abc.txt | ||
+ | filename=$(basename $filewithpath) | ||
+ | filenoext=${filename%%.*} | ||
+ | </code> | ||
+ | |||
+ | filename will have abc.txt | ||
+ | |||
+ | filenoext will have abc | ||
+ | |||
+ | |||