Command Combination

Conversion of number system in Linux shell

Using double brackets with echo, print, printf

  • To Decimal

echo $((2#00000001)) = 1
echo $((16#AB)) = 171
echo $((8#70) = 56
print $((8#70))
printf “%d\n $((8#70)). %d = decimal

Using obase,ibase and bc

Character in hex must be uppercase
echo “obase=10; ibase=16; AB” | bc
echo “obase=2; ibase=16; F” | bc

===========================================================================================================

Compare files

Comm

  • comm file1 file2

    • First column: Line not present in file1

    • Second column: line not present in file2

    • Third column: file present in both

Diff

  • diff file1 file2 [-u | -c]: unified or context format

    • -: line appears in first file only

    • +: line appears in second file only

Some Options

  • -y: compare side by side

Vimdiff

  • open multiple files in multiple vim windows

  • do: gets changes from the other window into the current one

  • dp: puts the changes from the current window into the other one

  • ]c: jumps to the next change

  • [c: jumps to the previous change

  • C w: switches to the other split window.

===========================================================================================================

Combination usage of sed, awk, cut, paste, cat, echo, grep

Combine each 2nd line to the line before it

Original data

Using AWK

Using Sed

Using Paste

Extract 1 line and all indented lines below it

Original data

Using AWK

  • cut -c 1-N

Check IP address of domain and print out domain, ip address or domain, not found

  • while read -r domain; do ip=$(host "$domain" | awk '/has address/ {print $4}'); echo "$domain,${ip:-not found}"; done < domains.txt

===========================================================================================================

Testing SMTP, SMTPS, HTTP, HTTPS using CLI commands

SMTP

SMTPS

Using SSL

Using TLS

  • other utilities

    • telnet-ssl: apt install telnet-ssl

    • gnutls-cli: apt install gnutls-cli

HTTP

HTTPS

Reference

  • https://unix.stackexchange.com/questions/184340/how-to-grep-a-line-with-unknown-number-of-its-indented-lines

  • https://qmail.jms1.net/test-auth.shtml

  • https://www.samlogic.net/articles/smtp-commands-reference-auth.htm

  • https://www.ndchost.com/wiki/mail/test-smtp-auth-telnet

Last updated