Skip to content

Instantly share code, notes, and snippets.

@ablwr
Created May 14, 2020 15:02
Show Gist options
  • Save ablwr/a5184749ab24795602805ee110874b94 to your computer and use it in GitHub Desktop.
Save ablwr/a5184749ab24795602805ee110874b94 to your computer and use it in GitHub Desktop.
make_json.sh
#!/bin/bash
printf '['
#
LC_ALL=C
for i in $(find ocrarchive/ -iname '*.txt');
do
printf '{"title":"'
printf "$i"
printf '","url":"'
printf "$i"
printf '","body":"'
cat -v "$i" | tr -cd '\11\12\15\40-\176' | tr -dc '\0-\177' | tr '\n' ' ' | tr '^+=%<>:\\#%|?*' ' ' | sed 's/"//g'
printf '"}\n,\n'
done
printf ']\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment