This pertains to #23 in that it fulfills functionality offered in POSIX by dd(1p), specifically dd conv=swab.
Usage: swab (-w [word size])
swab(1) swaps bytes in standard input to standard output. The default word size is 2, as in two-byte words with the latter half of the word (in this case, one byte) being output before the former half of the word.
$ swab
hello world
ehll oowlrd
If there are remaining bytes less than the word size they're left unconverted. Word sizes up to 16 (128 bits) will be supported.
$ echo hello world | swab -w 8
o wohellrld
The usefulness of such a tool is limited but this should be small and easy to make, and would fill in more POSIX functionality in a way that is simpler than POSIX.
This pertains to #23 in that it fulfills functionality offered in POSIX by dd(1p), specifically `dd conv=swab`.
```
Usage: swab (-w [word size])
```
swab(1) swaps bytes in standard input to standard output. The default word size is 2, as in two-byte words with the latter half of the word (in this case, one byte) being output before the former half of the word.
```sh
$ swab
hello world
ehll oowlrd
```
If there are remaining bytes less than the word size they're left unconverted. Word sizes up to 16 (128 bits) will be supported.
```sh
$ echo hello world | swab -w 8
o wohellrld
```
The usefulness of such a tool is limited but this should be small and easy to make, and would fill in more POSIX functionality in a way that is simpler than POSIX.
My current conundrum is that there are multiple useful types of byte reversal:
reversing bits in a byte
reversing bytes within a certain block size (e.g. "swabbing" - swapping bytes within a machine word - and the job of GNU tac(1), where all bytes in a file are reversed)
reversing bytes in blocks delimited by a certain byte sequence (e.g. GNU's rev(1), using '\n' or '\0')
The third should be relegated to a separate utility as it's higher level (plaintext) than endianness/bit order tomfoolery. Should the former two be separate utilities?
My current conundrum is that there are multiple useful types of byte reversal:
- reversing bits in a byte
- reversing bytes within a certain block size (e.g. "swabbing" - swapping bytes within a machine word - and the job of GNU tac(1), where all bytes in a file are reversed)
- reversing bytes in blocks delimited by a certain byte sequence (e.g. GNU's rev(1), using '\n' or '\0')
The third should be relegated to a separate utility as it's higher level (plaintext) than endianness/bit order tomfoolery. Should the former two be separate utilities?
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This pertains to #23 in that it fulfills functionality offered in POSIX by dd(1p), specifically
dd conv=swab.swab(1) swaps bytes in standard input to standard output. The default word size is 2, as in two-byte words with the latter half of the word (in this case, one byte) being output before the former half of the word.
If there are remaining bytes less than the word size they're left unconverted. Word sizes up to 16 (128 bits) will be supported.
The usefulness of such a tool is limited but this should be small and easy to make, and would fill in more POSIX functionality in a way that is simpler than POSIX.
swab(1) - swap bytesto `swab(1)` - swap bytesMy current conundrum is that there are multiple useful types of byte reversal:
The third should be relegated to a separate utility as it's higher level (plaintext) than endianness/bit order tomfoolery. Should the former two be separate utilities?
Ah, I didn’t realize GNU had a utility called
revalready. Will come up with another name.On first consideration, I think it makes sense for all three to be separate utilities.