News for hackers. Stuff that matters.
Re:Pipe Viewer – A Unix Utility You Should Know About by fuzztester on Wednesday November 20, 2024 @05:25PM (#42198757)
dd conv=swab is a cool and useful option. swab stands for swap bytes, iirc. guess what it is used for, those who don't already know.
Re:Pipe Viewer – A Unix Utility You Should Know About by codetrotter on Wednesday November 20, 2024 @06:30PM (#42199256)
> guess what it is used for, those who don't already know.

Changing the endianness of the data?

Re:Pipe Viewer – A Unix Utility You Should Know About by fuzztester on Wednesday November 20, 2024 @08:34PM (#42200139)
Exactly!

That's just what I used it for, early in my career, in a software troubleshooting case.

I was a newbie dev, tasked with converting some data from another machine / OS format on tape to a Unix machine format.

Was fairly new to Unix too.

Looked through man pages, found dd, could read and copy the data from tape drive to disk using it. But the data, while in ASCII, and English letters, seemed garbled. Seemed like actual words, but not quite, if you know what I mean. Something seemed off a bit.

I puzzled over it for a while, then checked the dd man page again. I saw the conv=swab option and its meaning, which is to swap adjacent bytes. (Typical Unix cryptic syntax, and I say that as a long term Unix guy). I probably was new to endianess at that time. This was in a pre-Internet time, so I could not google to check what endianness meant.

I added that option to my dd command line, and what was my shock and pleasure to see all the words coming out as proper English words, now, on the screen!

Then I knew that the tape contained actual data, not garbage. I saved it to disk under some file name.

Job done.

Re:Pipe Viewer – A Unix Utility You Should Know About by codetrotter on Thursday November 21, 2024 @07:04AM (#42203480)
Super neat! :D
Re:Pipe Viewer – A Unix Utility You Should Know About by fuzztester on Thursday November 21, 2024 @02:54PM (#42207950)
Thanks!
Re:Pipe Viewer – A Unix Utility You Should Know About by fuzztester on Thursday November 21, 2024 @04:17PM (#42208762)
Example:

$ echo "ehll,ow rodl" | dd conv=swab

# Should give:

hello, world

A bit like rot13, but with 2 as the length :)

https://en.m.wikipedia.org/wiki/ROT13