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

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

RE: [shell-script] Retorno de dados do awk sendo usado no shell


From: MrBiTs
Subject: RE: [shell-script] Retorno de dados do awk sendo usado no shell
Date: Fri, 26 Aug 2005 11:11:58 -0300

/*
Como eu passo o resulatdo de um comando awk para o shellscript?? A forma
abaixo eu já tentei, não deu certo... eu quero pegar o primeiro campo e
atribuir a uma variavel para ser usada depois!!!

a=awk -F ";" ' { print $1 } ' arquivo
*/

$ cat arquivo
VALOR1;VALOR2

$ A=$(awk -F ";" ' { print $1 } ' arquivo)
$ echo $A
VALOR1

Todo e qualquer comando pode ser executado e seu retorno armazenado em uma
variável utilizando-se a construção $( ). É possível usar apóstrofes,
também.


------------------------------------------
"There is still more Unix-nature in one
line of shell script than there is in ten
billion lines of C" 
Master Foo - Sh-bng Province - 530 B.C.
 
"Programar em shell scritp é a coisa mais gostosa que você pode fazer
vestido"
Julio C. Neves - 10/08/2005



reply via email to

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