en:programming:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:programming:start [2018/05/04 19:59] – external edit 127.0.0.1 | en:programming:start [2023/06/08 17:06] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Programming ====== | ||
+ | http:// | ||
+ | |||
+ | ===== Bash ===== | ||
+ | FIXME | ||
+ | |||
+ | ==== root-check ==== | ||
+ | <code bash> | ||
+ | if [ $UID -eq 0 ];then echo " | ||
+ | </ | ||
+ | ==== online-check ==== | ||
+ | <code bash> | ||
+ | ping -c 1 ${HOST} -W 1 >/ | ||
+ | if [ $? == 0 ]; | ||
+ | then | ||
+ | | ||
+ | fi | ||
+ | </ | ||
+ | ==== colors ==== | ||
+ | <code bash> | ||
+ | clr_red=$' | ||
+ | clr_green=$' | ||
+ | clr_yellow=$' | ||
+ | clr_blue=$' | ||
+ | clr_reset=$' | ||
+ | </ | ||
+ | <code bash> | ||
+ | echo ${clr_red}test${clr_reset} | ||
+ | </ | ||
+ | |||
+ | ==== logging ==== | ||
+ | log single command (only stderr) and view simultaneously (stdout+stderr) | ||
+ | <code bash> | ||
+ | #via Process Substitution (https:// | ||
+ | make 2> >( tee " | ||
+ | </ | ||
+ | log multiple lines/ | ||
+ | <code bash> | ||
+ | exec 3> >(tee logfile) | ||
+ | |||
+ | make alpha 2>&3 && | ||
+ | make bravo 2>&3 && | ||
+ | make charlie 2>&3 && success=1 | ||
+ | |||
+ | exec 3>&- | ||
+ | </ | ||
+ | |||
+ | ==== Case ==== | ||
+ | |||
+ | case " | ||
+ | *foo*) | ||
+ | #anything | ||
+ | ;; | ||
+ | [1-6]*) | ||
+ | # | ||
+ | ;; | ||
+ | *) | ||
+ | #all other | ||
+ | ;; | ||
+ | esac | ||
+ | ==== stringmanipulation ==== | ||
+ | In Bash 4: | ||
+ | all lowercase | ||
+ | |||
+ | $ echo " | ||
+ | |||
+ | all uppercase: | ||
+ | |||
+ | $ echo " | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | === path / filename === | ||
+ | |||
+ | <code bash> | ||
+ | $ VAR=/ | ||
+ | $ DIR=$(dirname " | ||
+ | $ echo " | ||
+ | / | ||
+ | $ basename " | ||
+ | file.c | ||
+ | </ | ||
+ | |||
+ | === substrings === | ||
+ | |||
+ | a=string | ||
+ | b=${a:p:l} | ||
+ | #p=Position (0-basiert), | ||
+ | |||
+ | === replace === | ||
+ | |||
+ | orig=" | ||
+ | mod=${orig// | ||
+ | |||
+ | === Regex-Check === | ||
+ | |||
+ | <code bash> | ||
+ | string=' | ||
+ | | ||
+ | if [[ $string =~ .*My.* ]] | ||
+ | then | ||
+ | echo " | ||
+ | fi | ||
+ | </ | ||
+ | ==== calculation ==== | ||
+ | |||
+ | GPIO_NO=$((232+25)) | ||
+ | |||
+ | ==== Number-Ranges ==== | ||
+ | |||
+ | ls IMG_20170923_{17..18}* | ||
+ | |||
+ | ==== terminal language ==== | ||
+ | |||
+ | temporary change language (e.g. to get errors in english for forums): | ||
+ | |||
+ | LANG=C | ||
+ | ===== Batch ===== | ||
+ | ===== C/C++ ===== | ||
+ | ===== CSS ===== | ||
+ | ===== JavaScript ===== | ||
+ | ===== HTML ===== | ||
+ | ===== PHP ===== | ||
en/programming/start.txt · Last modified: 2023/06/08 17:06 by 127.0.0.1