xargs tips

May 25, 2024 note-to-self

XARGS things to remember

  • xargs -p will show the command
  • find . -name "foo" -print0 | xargs -0 (<<< print0 null, xarg uses null instead of space, in case file names have spaces…)
  • git diff --name-only website|xargs grep -iH 'namespace'
  • find . -type f -print0 | xargs -0 -L1 bash -c 'test "$(tail -c 1 "$0")" && echo "No new line at end of $0"'
  • git diff --name-only website | xargs -L1 bash -c 'test "$(tail -c 1 "$0")" && echo "No new line at end of $0"'
  • redis-cli -n 0 --scan --pattern '*pattern*'| xargs redis-cli -n 0 unlink
  • find . -not \( -path "*/.git/*" -o -path "*/vendor/*" -o -path "*/node_modules/*" -o -path "*/all/libraries/*" -o -path "*/modules/contrib/*" -type d -prune \) -type f -print0 | xargs -0 -L1 bash -c 'test "$(tail -c 1 "$0")" && echo "No new line at end of $0"'
These posts are for my own understanding. Reader beware. Info may be wrong but it reflects my current understanding.