title: I'm trying to cut a string with a number of bytes. What is the problem with this for loop?
body: <p>Sorry in advance for the beginner question, but I'm quite stuck and keen to learn.</p>
  
  <p>I am trying to echo a string (in hex) and then cut a piece of that with cut command. It looks like this:</p>
  
  <pre><code>for y in "${Offset}"; do
    echo "${entry}" | cut -b 60-$y
  done
  </code></pre>
  
  <p>Where echo ${Offset} results in </p>
  
  <pre><code>75 67 69 129 67 567 69
  </code></pre>
  
  <p>I would like each entry to be printed, and then cut from the 60th byte until the respective number in $Offset.</p>
  
  <p>So the first entry would be cut 60-75.</p>
  
  <p>However, I get an error:</p>
  
  <pre><code>cut: 67: No such file or directory
  cut: 69: No such file or directory
  cut: 129: No such file or directory
  cut: 67: No such file or directory
  cut: 567: No such file or directory
  cut: 69: No such file or directory
  </code></pre>
  
  <p>I tried adding/removing parentheses around each variable but never got the right result. 
  Any help will be appreciated!</p>
  
  <p>UPDATE: updated the code with changed from markp-fuso. However, this codes still does not work as intended. I would like to print every entry based on the respective offset, but it goes wrong. This prints every entry seven times, where each time is based on seven different offsets. Any ideas on how to fix this?</p>
  
  <pre><code>#!/bin/bash
  
  MESSAGES=$( sqlite3 -csv file.db 'SELECT quote(data) FROM messages' | tr -d "X'" )
  
  for entry in ${MESSAGES}; do
  
    Offset='75 67 69 129 67 567 69'
    for y in $Offset; do
      echo "${entry:59:(y-59)}"
    done
  done
  </code></pre>
  
  <pre><code>echo ${MESSAGES}
  </code></pre>
  
  <p>Results in seven strings with minimal length 80 bytes and max 600.
  My output should be:</p>
  
  <p>String one: cut by first offset </p>
  
  <p>String two: cut by second offset
  and so on...</p>