Base64 in Bash: Encode and Decode Files from the Command Line
Use the base64 command in Linux/macOS to encode strings, encode files, decode output, and pipe data between tools. Covers macOS vs GNU differences.
Published:
Tags: encoding, bash, base64
Base64 in Bash: Encode and Decode Files from the Command Line The command is available on Linux (GNU coreutils) and macOS (BSD base64). The APIs differ slightly — the flag for line wrapping exists on Linux but not macOS, and vs are not interchangeable. This guide covers both platforms, with the patterns for encoding/decoding strings and files, piping, and shell scripting. Basic decoding works on both Linux and macOS, making it the safest choice for portable scripts. --- Encoding and decoding files Encoding a file Decoding a file --- Cross-platform scripts The key differences between GNU (Linux) and BSD (macOS) : | Feature | Linux (GNU) | macOS (BSD) | |---|---|---| | Decode flag | or | or | | Line wrap | (0 = no wrap) | Not supported | | Default line width | 76 chars | 76 chars | A robust…
All articles · theproductguy.in