diff --git a/tshell/tshell_p1.sh b/tshell/tshell_p1.sh index 7b3e4486c0d53216c89f7203a3bc17172914c2ee..df94547ba09b15fd5731e13ee29fe793d30dc580 100755 --- a/tshell/tshell_p1.sh +++ b/tshell/tshell_p1.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -lt 3 ] || [ $# -gt 5 ]; then - >&2 echo "Uso: <dpm> <ds> <t1> [<t2> [<t3>]]" + >&2 echo "Uso: ./tshell_p1.sh <dpm> <ds> <t1> [<t2> [<t3>]]" exit 1 fi @@ -13,7 +13,7 @@ T3=$5 if [ ! -d $FONTE ]; then >&2 echo "Erro: $FONTE não é um diretório." - exit 1 + exit 2 fi FONTE=$(realpath $FONTE) @@ -26,6 +26,6 @@ DESTINO=$(realpath $DESTINO) cd $FONTE for ARQ in *.csv; do - awk '(NR>1)' $ARQ | grep -iF "$T1" | grep -iF "$T2" | grep -iF "$T3" > $DESTINO/$ARQ + awk '(NR>1)' $ARQ | grep -iwF "$T1" | grep -iwF "$T2" | grep -iwF "$T3" > $DESTINO/$ARQ done cd - > /dev/null diff --git a/tshell/tshell_p2.sh b/tshell/tshell_p2.sh index 715f7a668bef882b125dd54b11940a1afb21df7f..01b878bd919ff0c93ff789752750b2eec7a7edea 100755 --- a/tshell/tshell_p2.sh +++ b/tshell/tshell_p2.sh @@ -1,14 +1,14 @@ #!/bin/bash if [ $# -ne 2 ]; then - >&2 echo "Uso: <dcsv> <dsin>" + >&2 echo "Uso: ./tshell_p2.sh <dcsv> <dsin>" exit 1 fi testa_diretorio() { if [ ! -d $1 ]; then >&2 echo "Erro: $1 não é um diretório." - exit 1 + exit 2 fi } diff --git a/tshell/tshell_p3.sh b/tshell/tshell_p3.sh index a9bf588e2f88457fdf73ac7361ef1d596fb81453..cab83f314f55c2e097bbafb971f20522b547c91a 100755 --- a/tshell/tshell_p3.sh +++ b/tshell/tshell_p3.sh @@ -1 +1,38 @@ #!/bin/bash + +if [ $# -ne 2 ]; then + >&2 echo "Uso: ./tshell_p3.sh <axml> <acsv>" + exit 1 +fi + +confere_arq_entrada() { + IFS=. read -r NOME EXT <<< $1 + if [ $EXT != "xml.gz" ]; then + >&2 echo "Erro: formato incorreto para $1 (deve ser .xml.gz)" + exit 2 + fi + if [ ! -f $1 ]; then + >&2 echo "Erro: $1 não existe" + exit 3 + fi +} + +confere_arq_saida() { + IFS=. read -r NOME EXT <<< $1 + if [ $EXT != "csv" ]; then + >&2 echo "Erro: formato incorreto para $1 (deve ser .csv)" + exit 2 + fi + + echo "version+pmid<title<abstract<keywords" > $1 +} + +XML=$1 +confere_arq_entrada $XML +XML=$(realpath $XML) + +CSV=$2 +confere_arq_saida $CSV +CSV=$(realpath $CSV) + +