Is there a unix/linux utility, perhaps a shell builtin or an external command, that will limit the number of bytes placed into a bash variable? For example, I want to make sure STRING
gets at most 1000 bytes (or some arbitrary number I choose) from the output of the curl
(or other) command:
STRING=$(curl -s http://localhost:8010/status?)
Let me edit this to make clear that I'm just using curl as an example, but I'd like this to work with any command.
Just add
-r 0-1000
to your curl commandline, i.e.:Or generically you can use
head -c 1000
, i.e.: