<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Bash-Hacks</title>
  <subtitle>One useful bash one-liner every weekday, explained flag by flag.</subtitle>
  <link href="https://bash-hacks.com/" />
  <link href="https://bash-hacks.com/atom.xml" rel="self" />
  <id>https://bash-hacks.com/</id>
  <updated>2026-11-02T00:00:00.000Z</updated>
  <entry>
    <title>Find the files that mention one thing but never mention another</title>
    <link href="https://bash-hacks.com/2026/11/02/050-find-files-that-mention-one-thing-but-not-another/" />
    <id>https://bash-hacks.com/2026/11/02/050-find-files-that-mention-one-thing-but-not-another/</id>
    <updated>2026-11-02T00:00:00.000Z</updated>
    <summary>grep -rl --null --include='*.js' 'fetch(' . | xargs -0 -r grep -L 'catch'</summary>
    <category term="files-search" />
  </entry>
  <entry>
    <title>Turn raw byte counts into human-readable sizes in any command's output</title>
    <link href="https://bash-hacks.com/2026/10/27/049-turn-byte-counts-into-human-readable-sizes/" />
    <id>https://bash-hacks.com/2026/10/27/049-turn-byte-counts-into-human-readable-sizes/</id>
    <updated>2026-10-27T00:00:00.000Z</updated>
    <summary>wc -c *.* | numfmt --field=1 --to=iec-i --suffix=B --padding=7</summary>
    <category term="dates-math" />
  </entry>
  <entry>
    <title>Find out whether a slow command is working or waiting</title>
    <link href="https://bash-hacks.com/2026/10/26/048-find-out-if-a-slow-command-is-working-or-waiting/" />
    <id>https://bash-hacks.com/2026/10/26/048-find-out-if-a-slow-command-is-working-or-waiting/</id>
    <updated>2026-10-26T00:00:00.000Z</updated>
    <summary>time du -sh /usr</summary>
    <category term="processes-jobs" />
  </entry>
  <entry>
    <title>Skip the header line of a file before you sort or count it</title>
    <link href="https://bash-hacks.com/2026/10/23/047-skip-the-header-line-of-a-file/" />
    <id>https://bash-hacks.com/2026/10/23/047-skip-the-header-line-of-a-file/</id>
    <updated>2026-10-23T00:00:00.000Z</updated>
    <summary>tail -n +2 sales.csv</summary>
    <category term="text-processing" />
  </entry>
  <entry>
    <title>Split a line into named variables without losing them to a subshell</title>
    <link href="https://bash-hacks.com/2026/10/22/046-split-a-line-into-variables-without-a-subshell/" />
    <id>https://bash-hacks.com/2026/10/22/046-split-a-line-into-variables-without-a-subshell/</id>
    <updated>2026-10-22T00:00:00.000Z</updated>
    <summary>IFS=, read -r date region product units revenue &lt;&lt;&lt; &quot;$(sed -n 2p sales.csv)&quot;; echo &quot;$region $units&quot;</summary>
    <category term="shell-tricks" />
  </entry>
  <entry>
    <title>See which commits are on a branch but not on main</title>
    <link href="https://bash-hacks.com/2026/10/21/045-see-which-commits-are-on-a-branch-but-not-on-main/" />
    <id>https://bash-hacks.com/2026/10/21/045-see-which-commits-are-on-a-branch-but-not-on-main/</id>
    <updated>2026-10-21T00:00:00.000Z</updated>
    <summary>git log --oneline main..feature</summary>
    <category term="git" />
  </entry>
  <entry>
    <title>Check whether a compressed backup is corrupt before you need it</title>
    <link href="https://bash-hacks.com/2026/10/15/044-check-whether-a-gzip-file-is-corrupt/" />
    <id>https://bash-hacks.com/2026/10/15/044-check-whether-a-gzip-file-is-corrupt/</id>
    <updated>2026-10-15T00:00:00.000Z</updated>
    <summary>gzip -tv *.gz</summary>
    <category term="archives-compression" />
  </entry>
  <entry>
    <title>Find out how much disk a file really uses, not how big it claims to be</title>
    <link href="https://bash-hacks.com/2026/10/14/043-find-out-how-much-disk-a-sparse-file-really-uses/" />
    <id>https://bash-hacks.com/2026/10/14/043-find-out-how-much-disk-a-sparse-file-really-uses/</id>
    <updated>2026-10-14T00:00:00.000Z</updated>
    <summary>ls -lsh *.img</summary>
    <category term="disk-system" />
  </entry>
  <entry>
    <title>Count from 01 to 12 with the zeros already in place</title>
    <link href="https://bash-hacks.com/2026/10/13/042-generate-a-zero-padded-number-sequence/" />
    <id>https://bash-hacks.com/2026/10/13/042-generate-a-zero-padded-number-sequence/</id>
    <updated>2026-10-13T00:00:00.000Z</updated>
    <summary>seq -w 1 12</summary>
    <category term="dates-math" />
  </entry>
  <entry>
    <title>Check whether a process is still alive without sending it anything</title>
    <link href="https://bash-hacks.com/2026/10/12/041-check-whether-a-process-is-still-alive/" />
    <id>https://bash-hacks.com/2026/10/12/041-check-whether-a-process-is-still-alive/</id>
    <updated>2026-10-12T00:00:00.000Z</updated>
    <summary>kill -0 4721 &amp;&amp; echo alive || echo gone</summary>
    <category term="processes-jobs" />
  </entry>
  <entry>
    <title>See a file's permissions as the number chmod expects</title>
    <link href="https://bash-hacks.com/2026/10/09/040-see-a-files-permissions-as-an-octal-number/" />
    <id>https://bash-hacks.com/2026/10/09/040-see-a-files-permissions-as-an-octal-number/</id>
    <updated>2026-10-09T00:00:00.000Z</updated>
    <summary>stat -c '%04a %A %U:%G %n' *</summary>
    <category term="files-search" />
  </entry>
  <entry>
    <title>Check if a remote port is open when netcat is not installed</title>
    <link href="https://bash-hacks.com/2026/10/08/039-check-if-a-port-is-open-without-netcat/" />
    <id>https://bash-hacks.com/2026/10/08/039-check-if-a-port-is-open-without-netcat/</id>
    <updated>2026-10-08T00:00:00.000Z</updated>
    <summary>timeout 3 bash -c '&lt;/dev/tcp/bash-hacks.com/443' &amp;&amp; echo open || echo closed</summary>
    <category term="networking" />
  </entry>
  <entry>
    <title>See which keys can log in to an account without reading base64</title>
    <link href="https://bash-hacks.com/2026/10/07/038-see-which-keys-can-log-in-to-an-account/" />
    <id>https://bash-hacks.com/2026/10/07/038-see-which-keys-can-log-in-to-an-account/</id>
    <updated>2026-10-07T00:00:00.000Z</updated>
    <summary>ssh-keygen -lf ~/.ssh/authorized_keys</summary>
    <category term="ssh-remote" />
  </entry>
  <entry>
    <title>Count who has actually committed to a repository, and how much</title>
    <link href="https://bash-hacks.com/2026/10/06/037-count-commits-per-author/" />
    <id>https://bash-hacks.com/2026/10/06/037-count-commits-per-author/</id>
    <updated>2026-10-06T00:00:00.000Z</updated>
    <summary>git shortlog -sne --no-merges HEAD</summary>
    <category term="git" />
  </entry>
  <entry>
    <title>Find out which stage of a pipeline actually failed</title>
    <link href="https://bash-hacks.com/2026/10/05/036-find-out-which-stage-of-a-pipeline-failed/" />
    <id>https://bash-hacks.com/2026/10/05/036-find-out-which-stage-of-a-pipeline-failed/</id>
    <updated>2026-10-05T00:00:00.000Z</updated>
    <summary>grep FATAL server.log | wc -l; echo &quot;${PIPESTATUS[@]}&quot;</summary>
    <category term="shell-tricks" />
  </entry>
  <entry>
    <title>Pull only the matching records out of a JSON file</title>
    <link href="https://bash-hacks.com/2026/10/02/035-pull-matching-records-out-of-a-json-file/" />
    <id>https://bash-hacks.com/2026/10/02/035-pull-matching-records-out-of-a-json-file/</id>
    <updated>2026-10-02T00:00:00.000Z</updated>
    <summary>jq -r '.servers[] | select(.cpu &gt; 60) | [.name, .ip, .cpu] | @tsv' data.json</summary>
    <category term="text-processing" />
  </entry>
  <entry>
    <title>Do decimal math in the shell when $(( )) only gives you integers</title>
    <link href="https://bash-hacks.com/2026/10/01/034-do-decimal-math-in-the-shell/" />
    <id>https://bash-hacks.com/2026/10/01/034-do-decimal-math-in-the-shell/</id>
    <updated>2026-10-01T00:00:00.000Z</updated>
    <summary>echo 'scale=3; 2/3' | bc</summary>
    <category term="dates-math" />
  </entry>
  <entry>
    <title>Find out which compressor actually wins on your data before you pick one</title>
    <link href="https://bash-hacks.com/2026/09/30/033-find-out-which-compressor-wins-on-your-data/" />
    <id>https://bash-hacks.com/2026/09/30/033-find-out-which-compressor-wins-on-your-data/</id>
    <updated>2026-09-30T00:00:00.000Z</updated>
    <summary>for c in gzip bzip2 xz; do printf '%-6s %10d\n' $c $($c -9 -c access.log | wc -c); done</summary>
    <category term="archives-compression" />
  </entry>
  <entry>
    <title>Read the load average without mistaking it for CPU usage</title>
    <link href="https://bash-hacks.com/2026/09/29/032-read-the-load-average-correctly/" />
    <id>https://bash-hacks.com/2026/09/29/032-read-the-load-average-correctly/</id>
    <updated>2026-09-29T00:00:00.000Z</updated>
    <summary>uptime</summary>
    <category term="disk-system" />
  </entry>
  <entry>
    <title>See the SSH settings a host will actually use before you connect</title>
    <link href="https://bash-hacks.com/2026/09/28/031-see-the-ssh-settings-a-host-will-actually-use/" />
    <id>https://bash-hacks.com/2026/09/28/031-see-the-ssh-settings-a-host-will-actually-use/</id>
    <updated>2026-09-28T00:00:00.000Z</updated>
    <summary>ssh -G devbox | grep -E '^(user|hostname|port|identityfile|proxyjump) '</summary>
    <category term="ssh-remote" />
  </entry>
  <entry>
    <title>Line up a CSV into readable columns right in the terminal</title>
    <link href="https://bash-hacks.com/2026/09/25/030-line-up-a-csv-into-readable-columns/" />
    <id>https://bash-hacks.com/2026/09/25/030-line-up-a-csv-into-readable-columns/</id>
    <updated>2026-09-25T00:00:00.000Z</updated>
    <summary>column -s, -t sales.csv</summary>
    <category term="text-processing" />
  </entry>
  <entry>
    <title>Pull the filename, directory, or extension out of a path without basename</title>
    <link href="https://bash-hacks.com/2026/09/24/029-pull-apart-a-path-without-basename/" />
    <id>https://bash-hacks.com/2026/09/24/029-pull-apart-a-path-without-basename/</id>
    <updated>2026-09-24T00:00:00.000Z</updated>
    <summary>p=/var/log/nginx/access.log.2.gz; echo &quot;${p##*/} ${p%/*} ${p%.*} ${p##*.}&quot;</summary>
    <category term="shell-tricks" />
  </entry>
  <entry>
    <title>Find out who actually wrote a line after a bulk reformat</title>
    <link href="https://bash-hacks.com/2026/09/23/028-find-who-actually-wrote-a-line-after-a-reformat/" />
    <id>https://bash-hacks.com/2026/09/23/028-find-who-actually-wrote-a-line-after-a-reformat/</id>
    <updated>2026-09-23T00:00:00.000Z</updated>
    <summary>git blame -w --ignore-revs-file .git-blame-ignore-revs src/auth.js</summary>
    <category term="git" />
  </entry>
  <entry>
    <title>Identify a file by what is inside it, not what it is called</title>
    <link href="https://bash-hacks.com/2026/09/22/027-identify-a-file-by-its-contents/" />
    <id>https://bash-hacks.com/2026/09/22/027-identify-a-file-by-its-contents/</id>
    <updated>2026-09-22T00:00:00.000Z</updated>
    <summary>file *</summary>
    <category term="files-search" />
  </entry>
  <entry>
    <title>See when a TLS certificate expires without opening a browser</title>
    <link href="https://bash-hacks.com/2026/09/21/026-see-when-a-tls-certificate-expires/" />
    <id>https://bash-hacks.com/2026/09/21/026-see-when-a-tls-certificate-expires/</id>
    <updated>2026-09-21T00:00:00.000Z</updated>
    <summary>openssl s_client -connect bash-hacks.com:443 -servername bash-hacks.com &lt;/dev/null 2&gt;/dev/null | openssl x509 -noout -subject -issuer -dates</summary>
    <category term="networking" />
  </entry>
  <entry>
    <title>See the resource limits every process inherits from your shell</title>
    <link href="https://bash-hacks.com/2026/09/18/025-see-the-limits-every-process-inherits/" />
    <id>https://bash-hacks.com/2026/09/18/025-see-the-limits-every-process-inherits/</id>
    <updated>2026-09-18T00:00:00.000Z</updated>
    <summary>ulimit -a</summary>
    <category term="disk-system" />
  </entry>
  <entry>
    <title>Do math on zero-padded numbers without the shell reading them as octal</title>
    <link href="https://bash-hacks.com/2026/09/17/024-do-math-on-zero-padded-numbers/" />
    <id>https://bash-hacks.com/2026/09/17/024-do-math-on-zero-padded-numbers/</id>
    <updated>2026-09-17T00:00:00.000Z</updated>
    <summary>echo $(( 10#$(date +%m) ))</summary>
    <category term="dates-math" />
  </entry>
  <entry>
    <title>See exactly what rsync will change before it changes anything</title>
    <link href="https://bash-hacks.com/2026/09/16/023-see-what-rsync-will-do-before-it-runs/" />
    <id>https://bash-hacks.com/2026/09/16/023-see-what-rsync-will-do-before-it-runs/</id>
    <updated>2026-09-16T00:00:00.000Z</updated>
    <summary>rsync -avni --delete site/ backup/</summary>
    <category term="ssh-remote" />
  </entry>
  <entry>
    <title>Total a column grouped by another one in a single pass</title>
    <link href="https://bash-hacks.com/2026/09/15/022-total-a-column-grouped-by-another/" />
    <id>https://bash-hacks.com/2026/09/15/022-total-a-column-grouped-by-another/</id>
    <updated>2026-09-15T00:00:00.000Z</updated>
    <summary>awk '{n[$7]++; bytes[$7]+=$10} END {for (u in n) printf &quot;%12.0f %6d %s\n&quot;, bytes[u], n[u], u}' access.log | sort -rn | head</summary>
    <category term="text-processing" />
  </entry>
  <entry>
    <title>Find the process that is quietly eating your memory</title>
    <link href="https://bash-hacks.com/2026/09/14/021-find-the-process-eating-your-memory/" />
    <id>https://bash-hacks.com/2026/09/14/021-find-the-process-eating-your-memory/</id>
    <updated>2026-09-14T00:00:00.000Z</updated>
    <summary>ps -eo pid,ppid,rss,etimes,pcpu,comm --sort=-rss | head -11</summary>
    <category term="processes-jobs" />
  </entry>
  <entry>
    <title>Search a project without walking into node_modules</title>
    <link href="https://bash-hacks.com/2026/09/08/018-search-a-project-without-walking-into-node-modules/" />
    <id>https://bash-hacks.com/2026/09/08/018-search-a-project-without-walking-into-node-modules/</id>
    <updated>2026-09-08T00:00:00.000Z</updated>
    <summary>find . \( -name node_modules -o -name .git \) -prune -o -type f -name '*.ts' -print</summary>
    <category term="files-search" />
  </entry>
  <entry>
    <title>Find out which part of an HTTP request is actually slow</title>
    <link href="https://bash-hacks.com/2026/09/07/017-find-out-which-part-of-a-request-is-slow/" />
    <id>https://bash-hacks.com/2026/09/07/017-find-out-which-part-of-a-request-is-slow/</id>
    <updated>2026-09-07T00:00:00.000Z</updated>
    <summary>curl -sS -o /dev/null -w &quot;dns   %{time_namelookup}\ntcp   %{time_connect}\ntls   %{time_appconnect}\nttfb  %{time_starttransfer}\ntotal %{time_total}\n&quot; https://www.debian.org</summary>
    <category term="networking" />
  </entry>
  <entry>
    <title>Bring back the commits you lost to a bad reset</title>
    <link href="https://bash-hacks.com/2026/09/04/016-bring-back-commits-lost-to-a-bad-reset/" />
    <id>https://bash-hacks.com/2026/09/04/016-bring-back-commits-lost-to-a-bad-reset/</id>
    <updated>2026-09-04T00:00:00.000Z</updated>
    <summary>git reflog show --date=relative HEAD</summary>
    <category term="git" />
  </entry>
  <entry>
    <title>Compare the output of two commands without writing a temp file</title>
    <link href="https://bash-hacks.com/2026/09/03/015-compare-the-output-of-two-commands/" />
    <id>https://bash-hacks.com/2026/09/03/015-compare-the-output-of-two-commands/</id>
    <updated>2026-09-03T00:00:00.000Z</updated>
    <summary>diff &lt;(sort packages-web01.txt) &lt;(sort packages-web02.txt)</summary>
    <category term="shell-tricks" />
  </entry>
  <entry>
    <title>Turn a Unix timestamp into a readable date in any timezone</title>
    <link href="https://bash-hacks.com/2026/09/02/014-read-a-unix-timestamp-in-any-timezone/" />
    <id>https://bash-hacks.com/2026/09/02/014-read-a-unix-timestamp-in-any-timezone/</id>
    <updated>2026-09-02T00:00:00.000Z</updated>
    <summary>TZ=America/New_York date -d @1788373391 +'%F %T %Z'</summary>
    <category term="dates-math" />
  </entry>
  <entry>
    <title>Reuse SSH connections instead of authenticating every time</title>
    <link href="https://bash-hacks.com/2026/09/01/013-reuse-ssh-connections-with-controlmaster/" />
    <id>https://bash-hacks.com/2026/09/01/013-reuse-ssh-connections-with-controlmaster/</id>
    <updated>2026-09-01T00:00:00.000Z</updated>
    <summary>ssh -o ControlMaster=auto -o ControlPath=~/.ssh/sockets/%r@%h-%p -o ControlPersist=600 devbox</summary>
    <category term="ssh-remote" />
  </entry>
  <entry>
    <title>See what is inside a tarball without extracting it</title>
    <link href="https://bash-hacks.com/2026/08/31/012-see-whats-inside-a-tarball-without-extracting/" />
    <id>https://bash-hacks.com/2026/08/31/012-see-whats-inside-a-tarball-without-extracting/</id>
    <updated>2026-08-31T00:00:00.000Z</updated>
    <summary>tar -tzvf archive.tar.gz</summary>
    <category term="archives-compression" />
  </entry>
  <entry>
    <title>Find out what a command actually is before you run it</title>
    <link href="https://bash-hacks.com/2026/08/28/011-find-out-what-a-command-actually-is/" />
    <id>https://bash-hacks.com/2026/08/28/011-find-out-what-a-command-actually-is/</id>
    <updated>2026-08-28T00:00:00.000Z</updated>
    <summary>type -a grep</summary>
    <category term="shell-tricks" />
  </entry>
  <entry>
    <title>Check how much disk space is left on every mounted filesystem</title>
    <link href="https://bash-hacks.com/2026/08/27/010-check-how-much-disk-space-is-left/" />
    <id>https://bash-hacks.com/2026/08/27/010-check-how-much-disk-space-is-left/</id>
    <updated>2026-08-27T00:00:00.000Z</updated>
    <summary>df -h</summary>
    <category term="disk-system" />
  </entry>
  <entry>
    <title>Search your Git history for a deleted function or string</title>
    <link href="https://bash-hacks.com/2026/08/26/009-search-git-history-for-deleted-code/" />
    <id>https://bash-hacks.com/2026/08/26/009-search-git-history-for-deleted-code/</id>
    <updated>2026-08-26T00:00:00.000Z</updated>
    <summary>git log -S&quot;handleAuth&quot; --oneline --all</summary>
    <category term="git" />
  </entry>
  <entry>
    <title>Check where a domain name actually points</title>
    <link href="https://bash-hacks.com/2026/08/25/008-check-where-a-domain-points/" />
    <id>https://bash-hacks.com/2026/08/25/008-check-where-a-domain-points/</id>
    <updated>2026-08-25T00:00:00.000Z</updated>
    <summary>dig +short example.com</summary>
    <category term="networking" />
  </entry>
  <entry>
    <title>Sort a CSV by any column without opening a spreadsheet</title>
    <link href="https://bash-hacks.com/2026/08/24/007-sort-csv-by-column/" />
    <id>https://bash-hacks.com/2026/08/24/007-sort-csv-by-column/</id>
    <updated>2026-08-24T00:00:00.000Z</updated>
    <summary>sort -t, -k3 -nr sales.csv | head -20</summary>
    <category term="text-processing" />
  </entry>
  <entry>
    <title>Find out what is actually eating your disk</title>
    <link href="https://bash-hacks.com/2026/08/21/006-find-what-is-eating-your-disk/" />
    <id>https://bash-hacks.com/2026/08/21/006-find-what-is-eating-your-disk/</id>
    <updated>2026-08-21T00:00:00.000Z</updated>
    <summary>du -h -d1 . | sort -hr | head -10</summary>
    <category term="files-search" />
  </entry>
  <entry>
    <title>Find out which process is sitting on port 8080</title>
    <link href="https://bash-hacks.com/2026/08/20/005-find-process-on-port-8080/" />
    <id>https://bash-hacks.com/2026/08/20/005-find-process-on-port-8080/</id>
    <updated>2026-08-20T00:00:00.000Z</updated>
    <summary>lsof -nP -iTCP:8080 -sTCP:LISTEN</summary>
    <category term="processes-jobs" />
  </entry>
</feed>