I’m really beginner in this field…
My question is: how can I create a structure in shell script (or bash, I’m not sure about the difference)
In C for example we can simply:
struct name
{
__u8 x;
__u8 y;
signed short z;
float t;
float u;
};
Is it possible to create something similar to this in shell?
Why?
I need to copy some values to a /proc file..but I need to be sure about they are 12 bytes, and the order of them, because I want to assign them to the previous structure which is inside a linux kernel module
Thank you for any useful answer or hint
May I suggest a better tool for the job, Python? It’s installed on most Linux systems, and you can write scripts with it, just put the appropriate shebang at the top:
Or,
Then use struct module to pack values into binary representation.
Which is equivalent to,
And can be invoked as:
EDIT: Or read from another file: