Skip to content

Instantly share code, notes, and snippets.

@bkw777
Last active July 23, 2025 17:13
Show Gist options
  • Save bkw777/92ed6327873ef96088475bedc44e2ba5 to your computer and use it in GitHub Desktop.
Save bkw777/92ed6327873ef96088475bedc44e2ba5 to your computer and use it in GitHub Desktop.
cat without cat
# minimal example just for reference, not pointful by itself
# binary-safe read/write file without cp/cat/dd etc, pure bash, no subshell
while LANG=C IFS= read -d '' -r -n 1 x ;do printf '%c' "$x" ;done <bin1 >bin2
@bkw777
Copy link
Author

bkw777 commented Jul 23, 2025

from a comment on another gist, slightly different version that reads non-nulls contiguously instead of every single byte individually
https://gist.github.com/bkw777/ddde771cc85fdd888c7ec74953193d66?permalink_comment_id=5686772#gistcomment-5686772

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment