shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [shell-script] Ordenar arquivo


From: Thobias Salazar Trevisan
Subject: Re: [shell-script] Ordenar arquivo
Date: Tue, 2 Oct 2001 16:39:55 -0300 (BRT)

        Mauricio,

        Acho que agora esta tudo num script so. Da uma olhada...

#!/bin/bash

if [ "$2" = "" ]; then
        echo "Usage: $0 <glob_file> <lang_file>"
        exit 1
fi

rm -f _sort.tmp

cat "$1" | while read;
do
        if [ `echo "$REPLY" | grep -c "define("` = "0" ]; then
                if [ -e _sort.tmp ]; then
                        sort -b -t '"' -k 2 _sort.tmp >> "new_$1"
                        rm -f _sort.tmp
                fi
                echo "$REPLY" >> "new_$1"
        else
                CHAVE="\"`echo "$REPLY" | cut -d '"' -f 2`\""
                LANG="`grep "$CHAVE" "$2"`"

                if [ "$LANG" = "" ]; then
                        echo "$REPLY" >> _sort.tmp
                else
                        PARAM="\"`echo "$LANG" | cut -d '"' -f 4`\""
                        echo "define($CHAVE,$PARAM);" >> _sort.tmp
                fi
        fi
done

echo "Created file new_$1"

        T+,
Thobias.

-- 
There's no saint like a reformed sinner.

----
Thobias Salazar Trevisan <address@hidden>
Home Page - http://www.cos.ufrj.br/~thobias
Parallel Computing Laboratory / COPPE
Federal University of Rio de Janeiro
Brazil
__________________________
|                        |
| Against - HTML Mail    |
|                        |
--------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]