Programmable completion

Simple completion using function _mycompletion() { local command_name="$1" # not used in this example local current_word="$2" local previous_word="$3" # not used in this example # COMPREPLY is an array which …

Devamını Oku..

Process substitution

Compare two files from the web The following compares two files with diff using process substitution instead of creating temporary files. diff <(curl http://www.example.com/page1) <(curl http://www.example.com/page2) Feed a while loop …

Devamını Oku..

Bash Arithmetic

Parameter DetailsEXPRESSION Expression to evaluate Simple arithmetic with (( )) #!/bin/bash echo $(( 1 + 2 )) Output: 3 # Using variables #!/bin/bash var1=4 var2=5 ((output=$var1 * $var2)) printf "%d\n" …

Devamını Oku..

Bash Script Math

Math using dc dc is one of the oldest programs on Unix. It uses reverse polish notation, which means that you first stack numbers, then operations. For example 1+1 iswritten …

Devamını Oku..

Basc Script Quoting

Double quotes for variable and command substitution Variable substitutions should only be used inside double quotes. calculation='2 * 3' echo "$calculation" # prints 2 * 3 echo $calculation # prints …

Devamını Oku..