У меня есть несколько файлов, и мне нужно сделать все, поэтому я использую поиск.мне нужно извлечь из .json строки 12 и извлечь идентификатор из .json.ml и объединить в CURL PUT
JSON-файл:
"title":"Hamaca",
"price":"620",
"currency_id":"ARS",
"available_quantity":"110",
"buying_mode":"buy_it_now",
"listing_type_id":"bronze",
"condition":"new",
"description":{
"plain_text": " Text Update"
},
"pictures":[
{"source":"https://web/img/p/2/9/29.jpg"},
{"source":"https://web/img/p/3/0/30.jpg"},
{"source":"https:/qweb/img/p/9/2/3/923.jpg"},
],
"attributes":[
{"id":"BRAND",
"value_name":" TIENDA" },
{"id":"MODEL",
"value_name":"Q" }]
Json.ml файл:
{"id":"MLA745474956","site_id":"MLA","title":"Hamaca","subtitle":null,"seller_id":335445253,"category_id":"MLA94987","official_store_id":null,"price":550,"base_price":550,"original_price":null,"currency_id":"ARS","initial_quantity":110,"available_quantity":110,"sold_quantity":0,"sale_terms":[],"buying_mode":"buy_it_now","listing_type_id":"gold_special","start_time":"2018-08-29T15:00:37.897Z","stop_time":"2038-08-24T04:00:00.000Z","end_time":"2038-08-24T04:00:00.000Z","expiration_time":"2018-11-17T15:00:38.018Z","condition":"new","permalink":"http://articulo.mercadolibre.com.ar/MLA-745474956-hamaca-_JM","pictures":[{"id":"706112-MLA28051912310_082018","url":"http://www.mercadolibre.com/jm/img?s=STC&v=O&f=proccesing_image_es.jpg","secure_url":"https://www.mercadolibre.com/jm/img?s=STC&v=O&f=proccesing_image_es.jpg","size":"500x500","max_size":"500x500","quality":""},{"id":"949384-MLA28051912309_082018","url":"http://www.mercadolibre.com/jm/img?s=STC&v=O&f=proccesing_image_es.jpg","secure_url":"https://www.mercadolibre.com/jm/img?s=STC&v=O&f=proccesing_image_es.jpg","size":"500x500","max_size":"500x500","quality":""},{"id":"803007-MLA28051912308_082018","url":"http://www.mercadolibre.com/jm/img?s=STC&v=O&f=proccesing_image_es.jpg","secure_url":"https://www.mercadolibre.com/jm/img?s=STC&v=O&f=proccesing_image_es.jpg","size":"500x500","max_size":"500x500","quality":""}],"video_id":null,"descriptions":[{"id":"MLA745474956-1797576680"}],"accepts_mercadopago":true,"non_mercado_pago_payment_methods":[],"shipping":{"mode":"me2","local_pick_up":false,"free_shipping":false,"methods":[],"dimensions":null,"tags":[],"logistic_type":"drop_off","store_pick_up":false},"international_delivery_mode":"none","seller_address":{"id":978130375,"comment":"","address_line":"Pastor Luna 6250","zip_code":"1682","city":{"id":"","name":"Tres de febrero"},"state":{"id":"AR-B","name":"Buenos Aires"},"country":{"id":"AR","name":"Argentina"},"latitude":-34.5861404,"longitude":-58.58094730000001,"search_location":{"neighborhood":{"id":"TUxBQlZJTDI2MTc2Mw","name":"Villa Bosch"},"city":{"id":"TUxBQ1RSRTMxODE5NA","name":"Tres de febrero"},"state":{"id":"TUxBUEdSQWVmNTVm","name":"Bs.As. G.B.A. Oeste"}}},"seller_contact":null,"location":{},"geolocation":{"latitude":-34.5861404,"longitude":-58.58094730000001},"coverage_areas":[],"attributes":[{"id":"ITEM_CONDITION","name":"Condición del ítem","value_id":"2230284","value_name":"Nuevo","value_struct":null,"attribute_group_id":"","attribute_group_name":""},{"id":"BRAND","name":"Marca","value_id":null,"value_name":"QUIEROTODO TIENDA","value_struct":null,"attribute_group_id":"OTHERS","attribute_group_name":"Otros"},{"id":"MODEL","name":"Modelo","value_id":null,"value_name":"QPM02","value_struct":null,"attribute_group_id":"OTHERS","attribute_group_name":"Otros"}],"warnings":[],"listing_source":"","variations":[],"thumbnail":"http://www.mercadolibre.com/jm/img?s=STC&v=I&f=proccesing_image_es.jpg","secure_thumbnail":"https://www.mercadolibre.com/jm/img?s=STC&v=I&f=proccesing_image_es.jpg","status":"active","sub_status":[],"tags":["immediate_payment","cart_eligible"],"warranty":"Cambios por falla de fabrica dentro de 72 hs de haber recibido el producto sin indicios de uso en su caja original! Los cambios de talle corren por cuenta del comprador de ida y vuelta sin exepcion. No hacemos reintegro de dinero ni devolcuion de art","catalog_product_id":null,"domain_id":"MLA-PLAYGROUND_SWING_SETS","seller_custom_field":null,"parent_item_id":null,"differential_pricing":null,"deal_ids":[],"automatic_relist":false,"date_created":"2018-08-29T15:00:38.208Z","last_updated":"2018-08-29T15:00:38.208Z","health":null}
Мне нужно извлечь строку 9 из json и id из json.ml Объединить в Curl
Thx
Вот мой код`
find . -type f -name '*.json' | xargs bash -c 'for fname
# Check if exist
do if [ ! -e ${fname}.ml ]
then
desc=$(sed -n "12p" ${fname})
id=$(cat ${fname}.ml | jq -r ".| .id " )
curl -X PUT -H "Content-Type: application/json" -d "$desc" https://api.web.com/id/$id/
else
(( acounte++ ))
fi
done
' bash
Когда я запускаю свой скрипт, ничего не работает, но я не вижу никакой ошибки.Thx