cliday

  • About

2022-12-09

December 9, 2022

CLI Tools

  1. grex: A command-line tool and Rust library for generating regular expressions from user-provided test cases
  2. cmatrix: Terminal based “The Matrix” like implementation

Interesting Links

  • Making Remote Development Even Better
  • CERN, Fermilab particle boffins bet on AlmaLinux for big science
  • How to use the lsof command to troubleshoot Linux
  • Create and share beautiful images of your source code

Tip of the Week

Use json output of popular commands:


% docker image list --format "{{json .}}"
% kubectl get pods --all-namespaces --output json
% gcloud projects list --format json

Use jqp to interactively parse the output:


% docker image list --format "{{json .}}" | jqp

Use jq to format the json output:


% docker image list --format "{{json .}}" | jq -rj '.ID,"\t",.Size,"\t",.Repository,":",.Tag,"\n"'
% kubectl get pods --all-namespaces --output json | jq -rc '.itmes[]|.spec.containers[]|.image'
% gcloud projects list --format json | jq -rj '.[]|select(.name|contains("My Project")|not)|.name,": ",.projectId,"\n"'

Continue reading

2022-12-02

December 2, 2022

CLI Tools

  1. fzf-tab: Replace zsh’s default completion selection menu with fzf
  2. bashate: Code style enforcement for bash programs

Interesting Links

  • How parameter expansion helps to not accidentally delete all the files on your machine
  • Advanced macOS Command-Line Tools

Tip of the Week

How to make dig a little easier to use:

The default output of dig includes the program version, technical information about the results, the query, the actual result, and statistics. Note: dig uses + instead of - for option flags.

# remove the version, technical info, query, and statistics sections:
% dig stackoverflow.com +nocmd +nocomment +noquestion +nostats
stackoverflow.com.      377     IN      A       151.101.193.69
stackoverflow.com.      377     IN      A       151.101.1.69
stackoverflow.com.      377     IN      A       151.101.65.69
stackoverflow.com.      377     IN      A       151.101.129.69

# the above can be re-written as:
% dig stackoverflow.com +noall +answer

# reduce the 'answer' portion even more:
% dig stackoverflow.com +short
151.101.193.69
151.101.1.69
151.101.65.69
151.101.129.69

# instead of an A record search, show other record types:
% dig NS stackoverflow.com +short
ns-cloud-e2.googledomains.com.
ns-cloud-e1.googledomains.com.
ns-1033.awsdns-01.org.
ns-358.awsdns-44.com.

% dig MX stackoverflow.com +short
1 aspmx.l.google.com.
10 alt3.aspmx.l.google.com.
10 alt4.aspmx.l.google.com.
5 alt2.aspmx.l.google.com.
5 alt1.aspmx.l.google.com.

# use a different DNS server (can help against caching):
% dig stackoverflow.com @9.9.9.9  # https://www.quad9.net

# do a reverse lookup:
% dig -x 185.199.111.153 +short
cdn-185-199-111-153.github.com.

# dig supports a config file, for example:
cat << EOF > ~/.digrc
+noall
+answer
EOF
Continue reading

2022-11-18

November 18, 2022

CLI Tools

  1. ddgr: DuckDuckGo from the terminal
  2. fname: Generate random, human-friendly names

Articles of Note

  • A brief interview with AWK creator Dr. Brian Kernighan
  • The history of how Unix started and influenced Linux
  • #gitPanic - Merging and Rebasing
  • How to make Linux feel like Unix

Tip of the Week

Reading man pages and getting help:

# on macOS, use Preview to open a man page:
% preman() { mandoc -T pdf "$(/usr/bin/man -w $@)" | open -fa Preview; }
% preman <command>

# alternatively, with `ps2pdf`:
% preman() { man -t tr | ps2pdf - | open -fa Preview; }

# open man page in a separate Terminal window:
% xmanpage() { open x-man-page://"$1"; }
% xmanpage <command>

# search man page titles:
% man -k <name>

# search man page contents:
% man -f <term>

# search user curated examples:
% curl cheat.sh/<topic>

Ref: On viewing man pages

Continue reading

2022-11-11

November 11, 2022

CLI Tools

  1. kube-linter: A static analysis tool that checks Kubernetes YAML to best practices
  2. shunit2: A xUnit based unit test framework for Bourne based shell scripts

Articles of Note

  • What happens when you delete a file in Linux?
  • Modern Cross-platform Command Line Tools to Supercharge Your Terminal
  • 7 Linux commands to gather information about your system
  • Ideal open source

Tip of the Week

Easily transform strings:

# reverse a string
% echo "this is a string" | rev
gnirts a si siht

# split a string
% echo "this is a string" | cut -d' ' -f1,4
this string

# make uppercase and lowercase
% foo="My String"
% echo $foo |  tr '[:upper:]' '[:lower:]'
my string
% echo ${foo:u}  # or ${foo^^} in Bash
MY STRING
% echo ${foo:l}  # or ${foo,,} in Bash
my string

# remove repeat letters
% bar="pool breeze puzzle tattoo"
% echo $bar | tr -s "ot"
pol breeze puzzle tato
% echo $bar | tr -s {a-z}  # {a-z} expands to all letters
pol breze puzle tato

# delete characters
% echo $bar | tr -d "aeiou"
pl brz pzzl ttt
Continue reading

2022-11-04

November 4, 2022

CLI Tools

  1. vhs: Your CLI home video recorder
  2. radio-cli: A simple radio CLI written in rust

Articles of Note

  • Linux world gains ability to repair exFAT drives
  • RIP: Kathleen Booth, the inventor of assembly language
  • Build FFmpeg filters without the headache

Tip of the Week

Get information about files:

# print lines, word count, and byte size:
% cat << EOF > /tmp/file.txt
It's a jetpack, Michael. What could go wrong?
You are a worse psychiatrist than you are a son-in-law and you will never get work as an actor because you have no talent.
If you're suggesting I play favorites, you're wrong. I love all of my children equally. I don't care for Gob.
EOF

% wc /tmp/file1.txt
3 52 279 file.txt  # 3 lines, 52 words, 279 bytes

# `stat` is a highly customizable program to show file and system info:
% stat file.txt
  File: file.txt
  Size: 279             Blocks: 8          IO Block: 4096   regular file
Device: 1,18    Inode: 33788754    Links: 1
Access: (0644/-rw-r--r--)  Uid: (  501/  bfrank)   Gid: (    0/   wheel)
Access: 2022-11-03 21:27:10.235710583 -0400
Modify: 2022-11-03 21:27:07.537350066 -0400
Change: 2022-11-03 21:27:07.537350066 -0400
 Birth: 2022-11-03 21:25:29.005628590 -0400

% stat -c "%F" /tmp/file.txt  # %F = file type
regular file

# `file` shows file type and metadata
% file /tmp/file.txt
file.txt: ASCII text

% file --mime-type file.txt
file.txt: text/plain
Continue reading
Prev Next

Powered by Jekyll with Type Theme