======MISC======
====Terminator=====
Personalized terminator settings:
shift+F10 #Preferences (if "PuTTY style paste" is active)
strg+shift+c #copy
strg+alt+h #split horizontally
strg+alt+v #split vertically
strg+alt+m #multiplex (groupalltoggle)
Terminator -> Preferences -> Profiles -> Scrolling #set lines of scollback (infinite or to amount of lines)
====jq====
jq - commandline JSON processor, to visualize json output in a readable way
Example unformated text-output:
cat test
[{"target_name":"mytarget","message":"Successfully processed","action_success":true}]
Output formated by piping in jq via command:
cat test | jq '.[] | select(.target_name == "mytarget" and .message == "Successfully processed" and .action_success = "true")'
{
"target_name": "mytarget",
"message": "Successfully processed",
"action_success": true
}
====Manipulating Strings====
https://tldp.org/LDP/abs/html/string-manipulation.html
Examples:
Ueb="String1_String2_String3"
Remove 1. string:
Ueb1=${Ueb#*_}
# echo $Ueb1
String2_String3
Keep 1. string:
Ueb1=${Ueb%%_*}
# echo $Ueb1
String1
Remove last string:
Ueb1=${Ueb%_*}
# echo $Ueb1
String1_String2
Keep last string:
Ueb1=${Ueb##*_}
# echo $Ueb1
String3
Another example:
# echo ${TEST:-Foo}
Foo
# echo $TEST
# echo ${TEST:=Foo}
Foo
# echo $TEST
Foo
====awk====
Examples:
# echo "somestring.or.url.com somestring1.or.url1.com" | awk '{print $1".to.add.anotherstring "$2".and.one.more"}'
somestring.or.url.com.to.add.anotherstring somestring1.or.url1.com.and.one.more
awk -F: /my-user/'{print $3}' /etc/passwd #getting uid of user "my-user"
java -version 2>&1 | awk -F '-' 'NR==2 {print $2}' #searching for "-" in string and cut all in between, but just from line 2 (NR==2) as the result has 3 lines
ifconfig -a | awk '/inet 10/{print $2}' #getting IP adress starting with "inet 10"
echo "somestring1 somestring2" | awk '{print $1,$2}'