All pastes #54503 Raw Edit

Miscellany

public text v1 · immutable
#54503 ·published 2006-05-09 12:03 UTC
rendered paste body
#!/bin/sh

usage1()
{
  echo USAGE : $0 \<fichier.bib\> \<-option\>
  exit 1
}

usage2()
{
  echo USAGE : $0 \<fichier.bib\> \<-option\> \<mot_cle ou nom\>
  exit 1
}

usage3()
{
  echo USAGE : $0 \<fichier.bib\> \<-option\> \<date debut\> \<date fin\>
  exit 1
}
if [ $# < 3 ]
then
  usage1
fi

if [ -r $1 ]
  then
  case $2 in
    -affichage) cat $1 ;;
    -affichage_texte) grep -v "@" $1 > projet.tmp
                      grep -v "}" projet.tmp
                      rm -f projet.tmp ;;
    -recherche) if [ $# != 3 ]
                then
                  usage2 ;
                else
                  if [ ' egrep -c "@$3" $1 ' != 0 ]
                  then
                    cat $1 | while read ligne ; do
                      if [ grep "$3" ligne > /dev/null ]
                      then
                        echo $ligne
                      fi
                    done
                  else
                    echo cherche
                  fi
                 fi ;;
    *) echo Les options valides sont \:
       echo \-affichage
       echo \-affichage_texte
       echo \-recherche
       echo \-auteur
       echo \-annees ;;
  esac
else
  echo pas de fichier
fi