Re: Bash script - egrep de coluna, print da linha inteira

2008-07-05 Por tôpico Fabiano
On 4 jul, 18:10, Rodrigo Escobar [EMAIL PROTECTED] wrote:
 heheh eu sei velho.. nao estou te questionando..
 sei que tu manda bem em shell tambem..

 E vc esta correto sim.. nesse modelo de arquivo que ele postou funciona
 perfeitamente.

 abs!

 2008/7/4 Junior Polegato - Linux [EMAIL PROTECTED]:



  Rodrigo Escobar escreveu:

  Ultima coluna não.. o grep so funciona se o valor ou cadeia de caracteres
  que seja.. '100,00' forem os ultimos caracteres da linha por causa do
  simbolo $
  :)

  Tem razão, mas para o arquivo em questão funcionaria. Mas o correto mesmo,
  para colunas separadas por espaços ou tabulações, seria:

  - Primeira: '^100.00[\t ]\+'
  - Última '[\t ]\+100.00$'
  - Conteúdo genérico de cada coluna: '[^\t ]\+'
  - Separador de cada coluna: '[\t ]\+'
  - Exemplo de 100.00 na terceira coluna: '^[^\t ]\+[\t ]\+[^\t ]\+[\t
  ]\+100.00[\t ]\+'
  - Dependendo da formatação do arquivo podem haver variações.

  PS: Aos poucos a gente vai melhorando... :)

  []'s
             Junior Polegato- Ocultar texto entre aspas -

 - Mostrar texto entre aspas -

-Fé o delimiador, no caso espaços ou tab para o seu arquivo
$0  o próprio arquivo
$1   primeira coluna
$2   segunda coluna e assim sucessivamente

na expressão:   $2 ~ 100  significa: segunda coluna que
contenha 100
na expressão:   {print $0} significa: imprima o
arquivo

awk -F   '$2 ~ 100 {print $0}'


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Bash script - egrep de coluna, print da linha inteira

2008-07-04 Por tôpico Rafael Gomes Dantas
Creio que você será mais feliz usando awk...

Dá uma olhada em como funciona e faça um script usando ele...
http://www.zago.eti.br/script/awk.html

On Thu, Jul 3, 2008 at 5:13 PM, Denis [EMAIL PROTECTED] wrote:

 #!/bin/bash

 Olá, alguem sabe como dar um grep em apenas uma coluna de uma linha e
 no resultado imprimir a linha inteira?

 Por exemplo, imprimir as linhas completas em todas as ocasioes que a
 ultima coluna possuir um 100

 Average:  126100.00  0.00  0.00  0.00  0.00
 Average:  127100.00  0.00  0.00  0.00  0.00
 Average:  128100.00  0.00  0.00  0.00  0.00
 Average:  129  0.00  0.00  0.00  0.00100.00
 Average:  130  0.00  0.00  0.00  0.00100.00
 Average:  131100.00  0.00  0.00  0.00  0.00
 Average:  132100.00  0.00  0.00  0.00  0.00
 Average:  133  0.00  0.00  0.00  0.00100.00
 Average:  134100.00  0.00  0.00  0.00  0.00
 Average:  135  0.00  0.00  0.00  0.00100.00



 thanks

 --
 Denis Anjos.
 Cisco Certified Network Associate.
 Universidade Federal do ABC
 Santo André - SP - BR


 --
 To UNSUBSCRIBE, email to [EMAIL PROTECTED]
 with a subject of unsubscribe. Trouble? Contact
 [EMAIL PROTECTED]




Re: Bash script - egrep de coluna, print da linha inteira

2008-07-04 Por tôpico Rodrigo Escobar
Para ajudar voce.. ta ai o comando e o respectivo resultado..


[EMAIL PROTECTED]:/home/rodrigo]$ cat tmp |awk -F  '{ if ($7 == 100.00)
print $0}'

Average:  129  0.00  0.00  0.00  0.00100.00
Average:  130  0.00  0.00  0.00  0.00100.00
Average:  133  0.00  0.00  0.00  0.00100.00
Average:  135  0.00  0.00  0.00  0.00100.00

abs!


On 7/4/08, Rafael Gomes Dantas [EMAIL PROTECTED] wrote:

 Creio que você será mais feliz usando awk...

 Dá uma olhada em como funciona e faça um script usando ele...
 http://www.zago.eti.br/script/awk.html

 On Thu, Jul 3, 2008 at 5:13 PM, Denis [EMAIL PROTECTED] wrote:

 #!/bin/bash

 Olá, alguem sabe como dar um grep em apenas uma coluna de uma linha e
 no resultado imprimir a linha inteira?

 Por exemplo, imprimir as linhas completas em todas as ocasioes que a
 ultima coluna possuir um 100

 Average:  126100.00  0.00  0.00  0.00  0.00
 Average:  127100.00  0.00  0.00  0.00  0.00
 Average:  128100.00  0.00  0.00  0.00  0.00
 Average:  129  0.00  0.00  0.00  0.00100.00
 Average:  130  0.00  0.00  0.00  0.00100.00
 Average:  131100.00  0.00  0.00  0.00  0.00
 Average:  132100.00  0.00  0.00  0.00  0.00
 Average:  133  0.00  0.00  0.00  0.00100.00
 Average:  134100.00  0.00  0.00  0.00  0.00
 Average:  135  0.00  0.00  0.00  0.00100.00



 thanks

 --
 Denis Anjos.
 Cisco Certified Network Associate.
 Universidade Federal do ABC
 Santo André - SP - BR


 --
 To UNSUBSCRIBE, email to [EMAIL PROTECTED]
 with a subject of unsubscribe. Trouble? Contact
 [EMAIL PROTECTED]





Re: Bash script - egrep de coluna, print da linha inteira

2008-07-04 Por tôpico Junior Polegato - Linux

Denis escreveu:

Olá, alguem sabe como dar um grep em apenas uma coluna de uma linha e
no resultado imprimir a linha inteira?
Por exemplo, imprimir as linhas completas em todas as ocasioes que a
ultima coluna possuir um 100
Average:  126100.00  0.00  0.00  0.00  0.00
Average:  127100.00  0.00  0.00  0.00  0.00
Average:  128100.00  0.00  0.00  0.00  0.00
Average:  129  0.00  0.00  0.00  0.00100.00
Average:  130  0.00  0.00  0.00  0.00100.00
Average:  131100.00  0.00  0.00  0.00  0.00
Average:  132100.00  0.00  0.00  0.00  0.00
Average:  133  0.00  0.00  0.00  0.00100.00
Average:  134100.00  0.00  0.00  0.00  0.00
Average:  135  0.00  0.00  0.00  0.00100.00
  


Olá,

$ grep '100.00$' arquivo.txt


[]'s
   Junior Polegato


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Bash script - egrep de coluna, print da linha inteira

2008-07-04 Por tôpico Denis
2008/7/4, Junior Polegato - Linux [EMAIL PROTECTED]:
 Denis escreveu:
  Olá, alguem sabe como dar um grep em apenas uma coluna de uma linha e
  no resultado imprimir a linha inteira?
  Por exemplo, imprimir as linhas completas em todas as ocasioes que a
  ultima coluna possuir um 100
  Average:  126100.00  0.00  0.00  0.00  0.00
  Average:  127100.00  0.00  0.00  0.00  0.00
  Average:  128100.00  0.00  0.00  0.00  0.00
  Average:  129  0.00  0.00  0.00  0.00100.00
  Average:  130  0.00  0.00  0.00  0.00100.00
  Average:  131100.00  0.00  0.00  0.00  0.00
  Average:  132100.00  0.00  0.00  0.00  0.00
  Average:  133  0.00  0.00  0.00  0.00100.00
  Average:  134100.00  0.00  0.00  0.00  0.00
  Average:  135  0.00  0.00  0.00  0.00100.00
 
 

 Olá,

 $ grep '100.00$' arquivo.txt


 []'s
   Junior Polegato


Caros, muitas idéias boas.

Obrigado pelo tempo de vocês!

Denis.



-- 
Denis Anjos.
Cisco Certified Network Associate.
Universidade Federal do ABC
Santo André - SP - BR


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Bash script - egrep de coluna, print da linha inteira

2008-07-04 Por tôpico Rafael Gomes Dantas
bah, do jeito fácil não tem graça. =\

On Fri, Jul 4, 2008 at 6:06 AM, Junior Polegato - Linux 
[EMAIL PROTECTED] wrote:

 Denis escreveu:

 Olá, alguem sabe como dar um grep em apenas uma coluna de uma linha e
 no resultado imprimir a linha inteira?
 Por exemplo, imprimir as linhas completas em todas as ocasioes que a
 ultima coluna possuir um 100


 Olá,

 $ grep '100.00$' arquivo.txt


 []'s
   Junior Polegato



 --
 To UNSUBSCRIBE, email to [EMAIL PROTECTED]
 with a subject of unsubscribe. Trouble? Contact
 [EMAIL PROTECTED]




Re: Bash script - egrep de coluna, print da linha inteira

2008-07-04 Por tôpico Gunther Furtado
2008/7/4 Rafael Gomes Dantas [EMAIL PROTECTED]:
 bah, do jeito fácil não tem graça. =\


...e só funciona se for a última coluna...

[...]

 $ grep '100.00$' arquivo.txt


[...]

-- 
Gunther Furtado
[EMAIL PROTECTED]


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Bash script - egrep de coluna, print da linha inteira

2008-07-04 Por tôpico Rodrigo Escobar
Ultima coluna não.. o grep so funciona se o valor ou cadeia de caracteres
que seja.. '100,00' forem os ultimos caracteres da linha por causa do
simbolo $
:)

abs

On Fri, Jul 4, 2008 at 4:38 PM, Gunther Furtado [EMAIL PROTECTED]
wrote:

 2008/7/4 Rafael Gomes Dantas [EMAIL PROTECTED]:
  bah, do jeito fácil não tem graça. =\
 

 ...e só funciona se for a última coluna...

 [...]

  $ grep '100.00$' arquivo.txt
 

 [...]

 --
 Gunther Furtado
 [EMAIL PROTECTED]


 --
 To UNSUBSCRIBE, email to [EMAIL PROTECTED]
 with a subject of unsubscribe. Trouble? Contact
 [EMAIL PROTECTED]




Re: Bash script - egrep de coluna, print da linha inteira

2008-07-04 Por tôpico Junior Polegato - Linux

Gunther Furtado escreveu:

2008/7/4 Rafael Gomes Dantas [EMAIL PROTECTED]:
  

bah, do jeito fácil não tem graça. =\


...e só funciona se for a última coluna...
  


Olá,

  Expressões regulares... Se fosse no começo seria '^100.00', a 
última '100.00$', a segunda coluna separa por espaço ou tabulação '^[^\t 
]\+[\t ]\+100.00', a terceira '^[^\t ]\+[\t ]\+[^\t ]\+[\t ]\+100.00', a 
quarta '^[^\t ]\+[\t ]\+[^\t ]\+[\t ]\+[^\t ]\+[\t ]\+100.00', e assim 
por diante, ou seja, o conteúdo de uma coluna é representado por '[^\t 
]\+' e a separação por '[\t ]\+'. Melhorou?


[]'s
 Junior Polegato


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Bash script - egrep de coluna, print da linha inteira

2008-07-04 Por tôpico Denis
Sempre perspicaz.

rs
Parabens. =)

Em 04/07/08, Junior Polegato - Linux[EMAIL PROTECTED] escreveu:
 Gunther Furtado escreveu:
  2008/7/4 Rafael Gomes Dantas [EMAIL PROTECTED]:
 
 
   bah, do jeito fácil não tem graça. =\
  
  
  ...e só funciona se for a última coluna...
 
 

 Olá,

  Expressões regulares... Se fosse no começo seria '^100.00', a última
 '100.00$', a segunda coluna separa por espaço ou tabulação '^[^\t ]\+[\t
 ]\+100.00', a terceira '^[^\t ]\+[\t ]\+[^\t ]\+[\t ]\+100.00', a quarta
 '^[^\t ]\+[\t ]\+[^\t ]\+[\t ]\+[^\t ]\+[\t ]\+100.00', e assim por diante,
 ou seja, o conteúdo de uma coluna é representado por '[^\t ]\+' e a
 separação por '[\t ]\+'. Melhorou?

 []'s
 Junior Polegato



 --
 To UNSUBSCRIBE, email to
 [EMAIL PROTECTED]
 with a subject of unsubscribe. Trouble? Contact
 [EMAIL PROTECTED]




-- 
Denis Anjos.
Cisco Certified Network Associate.
Universidade Federal do ABC
Santo André - SP - BR


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Bash script - egrep de coluna, print da linha inteira

2008-07-04 Por tôpico Junior Polegato - Linux

Rodrigo Escobar escreveu:
Ultima coluna não.. o grep so funciona se o valor ou cadeia de 
caracteres que seja.. '100,00' forem os ultimos caracteres da linha 
por causa do simbolo $

:)


Tem razão, mas para o arquivo em questão funcionaria. Mas o correto 
mesmo, para colunas separadas por espaços ou tabulações, seria:


- Primeira: '^100.00[\t ]\+'
- Última '[\t ]\+100.00$'
- Conteúdo genérico de cada coluna: '[^\t ]\+'
- Separador de cada coluna: '[\t ]\+'
- Exemplo de 100.00 na terceira coluna: '^[^\t ]\+[\t ]\+[^\t ]\+[\t 
]\+100.00[\t ]\+'

- Dependendo da formatação do arquivo podem haver variações.

PS: Aos poucos a gente vai melhorando... :)

[]'s
Junior Polegato


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Bash script - egrep de coluna, print da linha inteira

2008-07-04 Por tôpico Rodrigo Escobar
heheh eu sei velho.. nao estou te questionando..
sei que tu manda bem em shell tambem..

E vc esta correto sim.. nesse modelo de arquivo que ele postou funciona
perfeitamente.

abs!

2008/7/4 Junior Polegato - Linux [EMAIL PROTECTED]:

 Rodrigo Escobar escreveu:

 Ultima coluna não.. o grep so funciona se o valor ou cadeia de caracteres
 que seja.. '100,00' forem os ultimos caracteres da linha por causa do
 simbolo $
 :)


 Tem razão, mas para o arquivo em questão funcionaria. Mas o correto mesmo,
 para colunas separadas por espaços ou tabulações, seria:

 - Primeira: '^100.00[\t ]\+'
 - Última '[\t ]\+100.00$'
 - Conteúdo genérico de cada coluna: '[^\t ]\+'
 - Separador de cada coluna: '[\t ]\+'
 - Exemplo de 100.00 na terceira coluna: '^[^\t ]\+[\t ]\+[^\t ]\+[\t
 ]\+100.00[\t ]\+'
 - Dependendo da formatação do arquivo podem haver variações.

 PS: Aos poucos a gente vai melhorando... :)

 []'s
Junior Polegato



Re: Bash script - egrep de coluna, print da linha inteira

2008-07-03 Por tôpico Cláudio E. Elicker
On Thursday 03 July 2008, Denis wrote:
 #!/bin/bash

 Olá, alguem sabe como dar um grep em apenas uma coluna de uma linha e
 no resultado imprimir a linha inteira?

 Por exemplo, imprimir as linhas completas em todas as ocasioes que a
 ultima coluna possuir um 100

 Average:  126100.00  0.00  0.00  0.00  0.00
 Average:  127100.00  0.00  0.00  0.00  0.00
 Average:  128100.00  0.00  0.00  0.00  0.00
 Average:  129  0.00  0.00  0.00  0.00100.00
 Average:  130  0.00  0.00  0.00  0.00100.00
 Average:  131100.00  0.00  0.00  0.00  0.00
 Average:  132100.00  0.00  0.00  0.00  0.00
 Average:  133  0.00  0.00  0.00  0.00100.00
 Average:  134100.00  0.00  0.00  0.00  0.00
 Average:  135  0.00  0.00  0.00  0.00100.00



awk '{if ($7 == 100.00) print $0}'  arquivo

[]'s


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]