scp transferring file To transfer a file securely to another machine – type: scp file1.txt tom@server2:$HOME This example presents transferring file1.txt from our host to server2’s user tom’s home directory. …
Devamını Oku..File execution sequence
.bash_profile, .bash_login, .bashrc, and .profile all do pretty much the same thing: set up and definefunctions, variables, and the sorts. The main difference is that .bashrc is called at the …
Devamını Oku..Job Control
List background processes $ jobs [1] Running sleep 500 & (wd: ~) [2]- Running sleep 600 & (wd: ~) [3]+ Running ./Fritzing & First field shows the job ids. The …
Devamını Oku..Case statement
Simple case statement In its simplest form supported by all versions of bash, case statement executes the case that matches the pattern. ;; operator breaks after the first match, if …
Devamını Oku..Internal variables
An overview of Bash’s internal variables, where, how, and when to use them. Bash internal variables at a glance VariableDetailsFunction/script positional parameters (arguments). Expand as follows$* / $@$* and $@ …
Devamını Oku..Change shell
Find the current shell There are a few ways to determine the current shell echo $0 ps -p $$ echo $SHELL List available shells To list available login shells : …
Devamını Oku..Pattern matching and regular expressions
Get captured groups from a regex match against a string a='I am a simple string with digits 1234' pat='(.*) ([0-9]+)' [[ "$a" =~ $pat ]] echo "${BASH_REMATCH[0]}" echo "${BASH_REMATCH[1]}" echo …
Devamını Oku..Bash Script Debugging
Checking the syntax of a script with “-n” The -n flag enables you to check the syntax of a script without having to execute it: ~> $ bash -n testscript.sh …
Devamını Oku..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..