Ana Sayfa / Tag Archives: Linux (Sayfa 4)

Tag Archives: Linux

Brace Expansion

Modifying filename extension $ mv filename.{jar,zip} This expands into mv filename.jar filename.zip . Create directories to group files by month and year $ mkdir 20{09..11}-{01..12} Entering the ls command will …

Devamını Oku..

Customizing PS1

Colorize and customize terminal prompt This is how the author sets their personal PS1 variable: gitPS1(){ gitps1=$(git branch 2>/dev/null | grep '*') gitps1="${gitps1:+ (${gitps1/#\* /})}" echo "$gitps1" } #Please use …

Devamını Oku..

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..