diff --git a/cheat/cheatsheets/apt-get b/cheat/cheatsheets/apt-get index f46e1ef..b0347ce 100644 --- a/cheat/cheatsheets/apt-get +++ b/cheat/cheatsheets/apt-get @@ -23,3 +23,6 @@ apt-get -o Dir::Cache="/path/to/destination/dir/" -o Dir::Cache::archives="./" i # Show apt-get installed packages. grep 'install ' /var/log/dpkg.log + +# Silently keep old configuration during batch updates +apt-get update -o DPkg::Options::='--force-confold' ... diff --git a/cheat/cheatsheets/awk b/cheat/cheatsheets/awk index dbc670e..14d07de 100644 --- a/cheat/cheatsheets/awk +++ b/cheat/cheatsheets/awk @@ -6,3 +6,6 @@ printf '1:2:3' | awk -F ":" '{print $1+$2+$3}' # print a multiplication table seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?"\n":"\t")}' + +# Specify output separator character +printf '1 2 3' | awk 'BEGIN {OFS=":"}; {print $1,$2,$3}' diff --git a/cheat/cheatsheets/bash b/cheat/cheatsheets/bash index 5b7a702..571b3ca 100644 --- a/cheat/cheatsheets/bash +++ b/cheat/cheatsheets/bash @@ -18,3 +18,10 @@ set -x # Turn off debugging: set +x + +# Retrieve N-th piped command exit status +printf 'foo' | fgrep 'foo' | sed 's/foo/bar/' +echo ${PIPESTATUS[0]} # replace 0 with N + +# Lock file: +( set -o noclobber; echo > my.lock ) || echo 'Failed to create lock file' diff --git a/cheat/cheatsheets/openssl b/cheat/cheatsheets/openssl index 74a2511..9254c1c 100644 --- a/cheat/cheatsheets/openssl +++ b/cheat/cheatsheets/openssl @@ -19,3 +19,6 @@ openssl x509 -text -noout -in server.crt echo | openssl s_client -connect :443 2> /dev/null | \ awk '/-----BEGIN/,/END CERTIFICATE-----/' | \ openssl x509 -noout -enddate + +# Generate Diffie-Hellman parameters: +openssl dhparam -outform PEM -out dhparams.pem 2048 diff --git a/cheat/cheatsheets/tar b/cheat/cheatsheets/tar index efa615f..088137a 100644 --- a/cheat/cheatsheets/tar +++ b/cheat/cheatsheets/tar @@ -24,3 +24,8 @@ tar -jtvf /path/to/foo.tgz # To create a .gz archive and exclude all jpg,gif,... from the tgz tar czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/ + +# To use parallel (multi-threaded) implementation of compression algorithms: +tar -z ... -> tar -Ipigz ... +tar -j ... -> tar -Ipbzip2 ... +tar -J ... -> tar -Ipixz ...