assim? $ comando | awk -v RS='[ \t\n]' '/\.sh/' /util/shell/suporte_001.sh /usr/bin/sh/util/shell/suporte_002.sh /bin/sh/util/shell/suporte_003.sh
On Nov 16, 2007 12:32 PM, Info Suporte - Rodrigo Nery <[EMAIL PROTECTED]> wrote: > > Olá pessoal, > > Estou montando uma expressão regular, porém a mesma não está > funcionando a contento. Vejam os exemplos abaixo da saída do comando "ps": > > root 28051 1 0 15:11:59 ? 0:00 sh > /util/shell/suporte_001.sh arg01 arg02 > user1 6075 6074 0 11:01:00 ? 0:00 /usr/bin/sh > /util/shell/suporte_002.sh > user2 6075 6074 0 11:01:00 ? 0:00 /bin/sh > /util/shell/suporte_003.sh 001 002 003 > > Preciso obter o nome do shell que está rodando, para isso tenho > direciono o comando "ps -ef | grep <nome do shell> | grep -v grep" para um > arquivo temporário e executo os comandos "sed" abaixo: > > cat /tmp/temp01 | sed 's;^.* \(/.*\) [A-Za-z0-9].*$;\1;g' | sed > 's;^.* \(/.*\)$;\1;g' > > A saída é: > > /util/shell/suporte_001.sh arg01 > /util/shell/suporte_002.sh > /util/shell/suporte_003.sh 001 002 > > E deveria ser: > > /util/shell/suporte_001.sh > /util/shell/suporte_002.sh > /util/shell/suporte_003.sh > > O que posso fazer para obter a saída desejada (somente o nome do > shell, eliminando todos os argumentos, se houver)? > > Obrigado a todos! > Rodrigo > -- Tiago B Peczenyj Linux User #405772 http://peczenyj.blogspot.com/ "what does not kill us makes us stronger"
