Thursday, September 2, 2021

Shell Scripting Essentials

Redirect stderror to output

$ cat foo.txt > output.txt 2>&1  // 2 stderror, &1 std output

cat nopx.txt > outputx.txt 2>&1 

// since there is an error the error will get redirected to outputx.txt


Command chaining &&


ls -ltr && mvn test && mvn deploy


Git shell coloring

# Regular Colors

Black="\[\033[0;30m\]"        # Black

Red="\[\033[0;31m\]"          # Red

Green="\[\033[0;32m\]"        # Green

Yellow="\[\033[0;33m\]"       # Yellow

Blue="\[\033[0;34m\]"         # Blue

Purple="\[\033[0;35m\]"       # Purple

Cyan="\[\033[0;36m\]"         # Cyan

White="\[\033[0;37m\]"        # White

More: https://gist.github.com/vratiu/9780109

No comments:

Post a Comment