Skip to main content
1 of 4
user3082
  • 1k
  • 2
  • 12
  • 18

best way to partially step through a 25k string?

I have 25k characters.

I wish to write a script to print (printf is most portable I'm told) an arbitrary number of characters; stepping through them in order.

say:

command number

Where number can be any value of 1-25000, and get that output.

I would prefer to not have the data in a separate file (the easiest solution?), and I'd prefer to use only POSIX shell commands (to make the script as portable as possible: I'm aware awk or perl could whack this out simply).

Should I store this data in a variable? Or run my complete printf through a cut command (cut -c -$1)? Or is there another (better?) solution? Why might I choose one option over another option?

What other problems/caveats am I over-looking?

user3082
  • 1k
  • 2
  • 12
  • 18