#!/bin/bash
if [ "$#" -lt 1 ]; then
       echo "usage: pechkinonthemotobike post_index"
       exit 1
fi
if [ "$1" -gt 999999 ]; then
       echo "Error: invalid post_index"
       exit 1
fi
curl -s http://postindexapi.ru/$1.json | iconv -c -f utf-8 | sed 's/":"/,/g;s/","/\n/g;s/{"//g;s/"}//g' | csvlook