Hello all, I have been asked to exercise my shell scripting and it has been 10 plus years since I used to do it so I can not remember hardly anything and ask for your help.
What I need to do is copy a line out of a file that can be 10 to 100 characters long, I then need to parse this line into groups of ten and then each group of ten I need to convert them into the binary 1/0s.
So far I have been using the cut command but this is very dirty way of doing it and would like someone to kick start my memory :wall:
#!/bin/sh
K="/tmp/test1"
L="/tmp/test2"
M="/tmp/test3"
N="/tmp/test4"
Z="tmp/binStr"
grep -i -w ${USER1} ${a} | cut -d: -f2 >> $K
grep -i -w ${USER2} ${a} | cut -d: -f2 >> $L
\cp /tmp/TMP_MENU_$$ ${a}
cat $k | cut -c 1-10 >> $M
cat $K | cut -c 11-20 >> $M
cat $K | cut -c 21-30 >> $M
cat $K | cut -c 31-40 >> $M
cat $K | cut -c 41-50 >> $M
cat $K | cut -c 51-60 >> $M
cat $K | cut -c 61-70 >> $M
cat $K | cut -c 71-80 >> $M
cat $K | cut -c 81-90 >> $M
cat $K | cut -c 91-100 >> $M
echo "ibase=16;obase=2;<Please tell me I can use a Variable here?>" | bc >> $Z
#Then the same thing for $L >> $N
After I figure this out then the fun part happens, I have to do a logical OR against the two files and then convert the binary back to an integer and then put them back into 1 long string, but 1st things first. Any help is drastically appreciated.