• # Script shell

    Posté par (site web personnel) . En réponse au message Script qui scrute un fichier logs ?? Besoin d'aide. Évalué à 3.

    Je te recommande le bash scripting guide : http://www.tldp.org/LDP/abs/html/ c'est indispensable.
    Voici un petit script que j'ai écrit ya pas longtemps, ca peux peut etre te donner une idée de l'utilisation de grep, sed, awk, etc... Exécute le ligne par ligne et tu finira par tout maitriser.

    #!/bin/bash
    # This script was written in order to download Arte-radio RSS flow's file, if
    # they are not in directory, and prefix them with the current date.
    # See that I am changing mp3 -> ogg, and I remove _hq from the fileneme,
    # in order to download ogg vorbis. All the files are not in ogg format.

    # working directory
    cd /home/francois/My_music/autre/arteRadio/

    wget http://www.arteradio.com/makeRSS.do -O makeRSS.do
    cat makeRSS.do | grep title | sed -e 's///' | sed -e 's/<\/title>//'
    cat makeRSS.do | tr -t '"' " " | sed -e 's/mp3/ogg/' | sed -e 's/_hq//' | awk '/enclosure/ {print 3ドル}' > urlList

    echo

    while read url
    do
    filename=`echo $url | tr "/" " " | awk '{print 4ドル}'`
    filename2=`echo \`date --rfc-3339=date\`"__"$filename`
    if [ -e "$filename2" ]
    then
    echo "$filename2 ... présent !"
    else
    wget -c $url -O $filename2
    fi

    done < urlList

    rm urlList makeRSS.do

    Adhérer à l'April, ça vous tente ?