This is my script:
#!/usr/bin/env bash
set -e
set -o errexit
set -o nounset
# set -o xtrace
input="${1:-}"
table="${2:-}"
length=$(jq length $input)
step=25
for i in {0..${length}..${step}}
do
low_index=$i * ${step}
high_index=$low_index + ${step} - 1
echo $low_index
echo $high_index
jq \
--arg table "$table" \
--arg low_index $low_index \
--arg high_index $high_index \
'{$table: [.[$low_index:$high_index] | {"PutRequest": {"Item": map_values({S: .})}}]}' \
csvjson.json > dynamo_${table}_${low_index}-${high_index}.json
done
This is the context of my directory:
$ ls
csvjson.json splitter.sh
Nevertheless, I'm getting:
$ bash ./splitter.sh csvjson.json socs
./splitter.sh: line 19: csvjson.json: command not found