Bless you forceful hipster lime!

: Clippy, bash / zsh commands, CSS Color

dig – get host infos

dig is a tool for querying DNS nameservers for information about host addresses, mail exchanges, nameservers, and related information

mediatemple.com

Usage (terminal): dig any domain.com for any entry. Or query specific entry, e.g. MX record: dig MX domain.com

(mehr …)

shut down after time machine backup

sudo tmutil startbackup –block;shutdown -h +1; exit

(should create Time Machine backup and shut down 1 min after completion. !: Time Machine must not run already/be in preparation)

source: stackexchange (mixed contributions)

bash / zsh commands

  • Copy folder contents to another folder: cp -R folder1/. folder2
  • Copy from and to clipboard (macOS)
    • Output to clipboard: <somecommand> | pbcopy
    • file to clipboard: pbcopy < file.txt
    • Clipboard to file: pbpaste > file.txt
    • Filtered paste pbpaste | grep sometext
  • Find files and folders: find <PATH> -name "<FILE/FOLDER-NAME/[WILDCARD*]>"
    • Process every find example: find /path/to/file -name "*.xyz" | while read line; do; echo "do sth with $line"; done;
  • Change filedate: touch -t 201203101513 "$filename"  (YYYYMMDDHHSS)
  • Copy file with Date/Time appended: `now=`date +%y%m%d-%H%M;dest="<DEST-PATH>/<FILENAME>_$now.<EXT>"  then cp <SRC-PATH/-FILE> $dest;
  • Saving output to file ls -l > filename.txt
  • Read file permisson: stat <file>
  • Change file permission: chmod 644 <file> [s]
  • Download file to current folder: curl -o newfilename.jpg https://remote.url/filename.jpg
  • Brace expansion: echo h{e,a,u}llo  >  hello hallo hullo  [s]
  • Tilde expansion: `~/ = HOME, ~+ = PWD  [s]
  • Command substitution:$(command) or  `command`  eg.: echo `date`  >  Thu Feb 6 10:06:20 CET 2003  [s]
  • Encode image base64: encoded=$( base64 Image.jpg ) then echo $encoded  or save it to output (see above)
  • List all connected USB devices: ioreg -p IOUSB [s]
  • line break: \n
  • Find out what shell is being usesd: echo "$SHELL"
  • Colorizing: echo -e "\033[31m Hello World"
  • Link folders (alias)ln -s target-file-folder alias-file-folder
    • e.g. ln -s project/theme-folder wpinstall.local/wp-content/themes

Batch proccess files in directory

whithin the file directory (in this example: convert to /done/ sub dir)

for filename in *.png
do
   convert "$filename" "done/"$filename
done

Menu

#!/bin/bash
# Bash Menu Script Example

PS3='Please enter your choice: '
options=("Option 1" "Option 2" "Option 3" "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "Option 1")
            echo "you chose choice 1"
            ;;
        "Option 2")
            echo "you chose choice 2"
            ;;
        "Option 3")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Quit")
            break
            ;;
        *) echo "invalid option $REPLY";;
    esac
done
  • save as XYZ.sh , run with sh XYZ.sh
  • See: ask ubuntu

about_self

  • whoami – computer name
  • ipconfig getifaddr en0 – current network ip adress
  • hostname – …
  • nslookup <IP_ADDRESS> – Server/Address/Name
  • host <IP_ADDRESS>