Jump to content

Building a packet format drawer in bash scripting with few lines of code


Go to solution Solved by requinix,

Recommended Posts

U-DLCI,6
C/R,1
EA,1
L-DLCI,4
FECN,1
BECN,1
DE,
EA,1

This is a file called table.csv

Now, what I what I want is this.

The 2nd column values are in bits.

bits_per_line=8

Now, I traverse through the file and save the first and second column values into an array.

packet_arr=("U-DLCI" "C/R" ....)

count_arr=(6 1 1 ...)

Now I start a counter that will count if bits_per_line ls over 8, if so, I do a new line.

counter=6+1+1

This counter will act upon every line.

Then I just print the contents.

I can't seem to write a bash shell scripting code for this however, (Even though I have completed tons of udemy courses and made many stuffs).

  • Solution

Not sure I get what you're trying to get out of this, but I would expect a read/while loop should be able to get the two values in each line, append the values to two arrays, do some quick math with a counter to determine "line" things...

What have you tried so far, what did you expect it to do, and what did it actually do?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.