Even More Useful Linux Examples

Continuing my series on “Useful-Linux-Examples”, yet another eclectic collection of useful things in Linux

Run commands for every line in a file (with parallelism)

Example running du -s for each line

parallel -a list-of-file-paths.txt -k du -s {}

Important flags:

  • -a reading from the file, line by line
  • -k preserves order

Monitor the progress of a file lines being generated

watch wc -l my-updating-file.txt

Important flags:

  • -n interval in seconds
  • -d highlight difference

Git

A safer version of git push -f / git push --force

git push --force-with-lease

Add a template repo as a remote to continue to pull updates with their commit messages

git remote add template [template repo]
git fetch --all
git merge template/[branch name] --allow-unrelated-histories

Alternatively, if the template repo is a cookiecutter repo, the following might be better

Get new updates from cookiecutter repo

Check out cruft

Even if the repo was originally started from vanilla cookiecutter, cruft can take over with just the commit of the template repo

Useful packages / commands

  • copier: Alternative updatable template repo tool
  • just: Makefile replacement for project commands