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

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

Re: [shell-script] Usando awk + sub


From: Gustavo Soares [SLot]
Subject: Re: [shell-script] Usando awk + sub
Date: Mon, 01 Apr 2013 16:40:13 -0300
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130107 Thunderbird/17.0.2

Abaixo um pedaço o danado, estou agora só testando as dicas de vcs.

######
RESULTADO=(`awk 'NR=1 {if ( $1 == "JasperPrint" ) print $2}' /tmp/lp_$$ | sed 's|\.| |g;s|-| |g'`) && {
      PROGRAMA=${RESULTADO[0]}
      VERSAO=${RESULTADO[1]}
      FMAC=${RESULTADO[2]}
      # transforma em lowercase.
      PATH_RS=$(dftype ${PROGRAMA,,}.flx) || {
        # se a variavel vier vazia ele ira parar a execucao.
(: ${PATH_RS:?}) 2> /dev/null || ( echo "VARIAVEL PATH_RS ESTA VAZIA"; exit; ) && PATH_RS=$(echo ${PATH_RS} | cut -f9 -d " ")
      }
   }
#######

Uai pessoal, bora arrumar um jeito de tomar umas em BH, ou onde vcs escolherem, um encontro do grupo seria bem interessante.


Eu animo demais.



Em 01-04-2013 16:18, Leslie Watter escreveu:
Oi Gustavo,

Voc� pode tentar colocar o gsub dentro do if :D que deve funcionar e
atender ao teu caso

awk 'NR=1 {if ( $1 == "JasperPrint" )  gsub("[.-]"," ",$1)};};'
/tmp/jasper2.txt


[]s

LEslie

2013/4/1 Gustavo Soares [SLot] <address@hidden>

**


Acabei usando da forma que voc� me passou, mas ele imprime TODO o
documento, como eu delimitei no in�cio para fazer somente a primeira
linha, n�o gostaria de ter que usar o head para isso.

Alguma id�ia ?

root@testejava:/root>awk 'NR=1 {if ( $1 == "JasperPrint" ) $1 };
{gsub(/-/," ",$1)}; {gsub(/\./," ",$1); print}' /tmp/jasper2.txt |
head -n1

LBANCO 703 687
root@testejava:/root>

Em 01-04-2013 16:06, Leslie Watter escreveu:
awk 'gsub(/-/," ",$0)

--
-------------------
SLot
Linux User: 124842
XMPP: address@hidden





--
-------------------
SLot
Linux User: 124842
XMPP: address@hidden



reply via email to

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