archx
Print machine architecture.
Mirrors GNU arch. Run it as archx, or as gnux archx.
Synopsis
archx [OPTION]...GNU reference
Description
archx prints the machine hardware name, exactly as unamex -m does, and takes no operands. The name comes from the operating system: x86_64 or aarch64 on Linux, x86_64 or arm64 on macOS, amd64 or arm64 on FreeBSD. On Windows, and in the browser playground, gnux names the architecture it was built for the way Linux does (x86_64, aarch64, wasm32).
Permissions
Needs no permissions. Reads only system information.
Use cases
- Picking the right binary to download in an
installscript. - Recording the machine's architecture in a CI log or a bug report.
- Skipping a step that only works on one architecture.
- Naming build output after the architecture it was built on.
- Checking whether a shell runs under emulation (Rosetta, QEMU).
Flags
--help display this help and exit
--version output version information and exitExamples
Print the machine architecture
archxx86_64Print the same name through unamex
unamex -mPick a download for this machine
curl -LO "https://example.com/tool-$(archx).tar.gz"Run a step only on 64-bit ARM
case "$(archx)" in aarch64|arm64) echox 'ARM build' ;; esacName an output directory after the architecture
mkdirx -p "build/$(archx)"Record the system in a log
echox "$(unamex -s) $(archx)" >> build.logSave the architecture in a variable
arch=$(archx)Print the architecture and the number of processors
echox "$(archx), $(nprocx) cores"Compare with the expected architecture
[ "$(archx)" = x86_64 ] || echox 'not x86_64'Branch on the architecture in the portable gnux shell
gnux shell -c 'case $(archx) in x86_64) echox intel ;; *) echox other ;; esac'Exit status
| Status | Meaning |
|---|---|
| 0 | success: every operand was processed |
| 1 | failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake |
Help in the terminal
archx --help # options, first examples, exit status
gnux help archx # this page: the full manual
gnux help archx --OPTION # one option in depth, with its examplesSee also
Windows and PowerShell
How to use gnux on Windows, where the GNU core utilities are otherwise missing: installing gnux.exe, making the per-tool commands with copies, hard links or symbolic links, why PowerShell's built-in aliases (rm, cp, ls, cat and more) are one of the reasons every tool carries an x suffix, how PowerShell's quoting, wildcard and redirection rules interact with native programs, how to write Windows paths such as C:\tools in gnux shell scripts, and exactly which features degrade on NTFS: symbolic links, owners and groups, permission modes and device numbers.
b2sumx
Print or check BLAKE2b (512-bit) checksums.