アマゾンの URL から ASIN を抽出する正規表現
Nid: 921
sed で"/"につづく10ケタの英数字を抽出。
$ while read line; do echo "$line" | sed -rn 's/.*\/(\w{10}).*/\1/p' ; done < urllist.txt B01M0KMGEQ 4487807433 B01DF3IQF4 B00UCPMTHA B00CPVWXDO B01ABS72SI B00SR46MOE B01LTHP0NY
使用したURLリスト
$ cat urllist.txt https://www.amazon.co.jp/Gibson-HP-635-W-%E3%82%AE%E3%83%96%E3%82%BD%E3%83%B3/dp/B01M0KMGEQ/ref=lp_2129866051_1_2?s=musical-instruments&ie=UTF8&qid=1491927843&sr=1-2 https://www.amazon.co.jp/%E3%83%87%E3%82%A3%E3%82%BA%E3%83%8B%E3%83%BC%E3%83%BB%E3%82%A4%E3%83%B3%E3%82%B0%E3%83%AA%E3%83%83%E3%82%B7%E3%83%A5%E3%83%BB%E3%82%B9%E3%82%BF%E3%83%B3%E3%83%80%E3%83%BC%E3%83%89%E3%83%BB%E3%82%B3%E3%83%AC%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3-%E3%83%90%E3%83%A9%E3%82%A8%E3%83%86%E3%82%A3-%E3%83%87%E3%82%A3%E3%82%BA%E3%83%8B%E3%83%BC%E3%83%BB%E3%82%A8%E3%83%B3%E3%82%BF%E3%83%BC%E3%83%97%E3%83%A9%E3%82%A4%E3%82%BA/dp/4487807433/ref=sr_1_2?m=AN1VRQENFRJN5&s=books&ie=UTF8&qid=1491930699&sr=1-2 https://www.amazon.co.jp/gp/product/B01DF3IQF4/ref=s9_acsd_ri_bw_rw_r0_p2_t_w?pf_rd_m=AN1VRQENFRJN5&pf_rd_s=merchandised-search-8&pf_rd_r=BJ64924GEAWVC25ZV1A9&pf_rd_r=BJ64924GEAWVC25ZV1A9&pf_rd_t=101&pf_rd_p=7b544c1a-491e-4e96-9572-5bb675635377&pf_rd_p=7b544c1a-491e-4e96-9572-5bb675635377&pf_rd_i=71668051 https://www.amazon.co.jp/Daiwa-%E3%83%80%E3%82%A4%E3%83%AF-%E3%82%B0%E3%83%A9%E3%83%B3%E3%83%89%E3%82%B9%E3%83%AA%E3%83%A0-95%E3%83%BBK-%E9%AE%8E%E7%AB%BF/dp/B00UCPMTHA/ref=sr_1_2?s=sports&ie=UTF8&qid=1491930526&sr=1-2 https://www.amazon.co.jp/%E3%83%90%E3%83%AC%E3%83%B3%E3%82%BF%E3%82%A4%E3%83%B32017-%E8%A8%B3%E3%81%82%E3%82%8A-%E3%81%B5%E3%81%9E%E3%82%8D%E3%81%84%E3%81%94%E8%87%AA%E5%AE%85%E7%94%A8-%E7%94%9F%E3%83%81%E3%83%A7%E3%82%B3-%E6%BF%83%E5%8E%9A%E3%83%97%E3%83%AC%E3%83%BC%E3%83%B3280g/dp/B00CPVWXDO/ref=sr_1_3?s=food-beverage&ie=UTF8&qid=1491930881&sr=1-3 https://www.amazon.co.jp/%E4%BA%80%E7%94%B0%E3%81%AE%E6%9F%BF%E3%81%AE%E7%A8%AE-%E4%BA%80%E7%94%B0%E8%A3%BD%E8%8F%93-%E4%BA%80%E7%94%B0%E3%81%AE%E6%9F%BF%E3%81%AE%E7%A8%AE6%E8%A2%8B%E8%A9%B0-200g/dp/B01ABS72SI/ref=lp_71314051_1_14?ie=UTF8&qid=1491930652&sr=1-14 https://www.amazon.co.jp/%E3%83%96%E3%83%A9%E3%83%83%E3%82%AF%E3%83%99%E3%83%AA%E3%83%BC-%E5%A4%A7%E6%A0%AA-%E6%9C%A8%E8%8B%BA-%E9%A3%9F%E7%94%A8%E5%8F%AF-%E8%90%BD%E8%91%89%E5%8D%8A%E3%81%A4%E3%82%8B/dp/B00SR46MOE/ref=sr_1_cc_3?s=aps&ie=UTF8&qid=1491931022&sr=1-3-catcorr&keywords=%E3%83%96%E3%83%A9%E3%83%83%E3%82%AF%E3%83%99%E3%83%AA%E3%83%BC%E3%81%AE%E7%A8%AE https://www.amazon.co.jp/gp/product/B01LTHP0NY/ref=s9_acsd_top_hd_bw_b2PcK_c_x_4_w?pf_rd_m=AN1VRQENFRJN5&pf_rd_s=merchandised-search-2&pf_rd_r=ZAEY8FB9NHY78ESB4KRK&pf_rd_r=ZAEY8FB9NHY78ESB4KRK&pf_rd_t=101&pf_rd_p=89a8802a-6cae-4c81-915b-446d56405925&pf_rd_p=89a8802a-6cae-4c81-915b-446d56405925&pf_rd_i=575132