#!/bin/bash # definition du nom du fichier de sortie avec la date du jour ofile=$(date +"%d-%b".txt) # initialisation de total au frais de port total=9.90 # Declaration d'une liste contenant les URL declare -A device_list device_list=( ["Mere"]="http://www.grosbill.com/4-asrock_b75m_itx_-163764-informatique-_carte_mere" \ ["Graphique"]="http://www.grosbill.com/4-asus_ati_radeon_hd6670_-164090-informatique-ati" \ ["CPU"]="http://www.grosbill.com/4-intel_core_i5_3350p_3_1ghz_6mo_cache_sans_graphique_socket_lga1155_-166202-informatique-_processeur" \ ["Boitier"]="http://www.grosbill.com/4-cooler_master_cm_690_ii_advanced_black_and_white_-169848-informatique-boitier" \ ["RAM"]="http://www.grosbill.com/4-x-168285-x-xx" \ ["Alim"]="http://www.grosbill.com/4-fortron_raider_550w_-190863-informatique-alimentation_atx" \ ["Fan"]="http://www.grosbill.com/4-aerocool_shark_white_edition_120mm_-173184-informatique-ventilateur_boitier" \ ["Clavier"]="http://www.grosbill.com/4-bluestork_kb_mediafirst2_-143786-peripheriques-clavier" \ ) # Pour chaque composant, recuperer le prix et l'ajouter au total # La ligne contenant le prix est celle-ci : # # donc le search pattern est # .*content="\(.*\)" \/> for device in "${!device_list[@]}" do price=$(wget ${device_list["$device"]} -O - -o /dev/null\ | grep 'itemprop="price"' | sed -e 's/.*content="\(.*\)" \/>/\1/') total=$(echo $total + $price | bc) echo -e "$device \t $price" >> $ofile; done echo -e "TOTAL \t $total" >> $ofile; # Ranger les donnees dans le fichier en colonnes et reecrire le fichier column -t $ofile | tee $ofile