23 Mar 2025 |
emanresu3 | e sim, o script ficaria melhor asim:
set -- /home/myra/*teste.txt*
if [ $# -ne 1 ]; then
echo "$#"
exit 1
esac
| 18:20:06 |
emanresu3 | In reply to @telegram_229478429:t2bot.io Saudações moçada! 🤙
Acabei de publicar um artigo sobre BATS e como aplicar TDD no Bash.
espero que seja útil para alguém!
qualquer feedback é bem vindo 🧡
https://meleu.sh/tdd-bash/ interessante artigo 👌, eu pessoalmente uso shellspec para TDD e gettext para traduzir idiomas | 18:23:56 |
25 Mar 2025 |
| Erika Brito🏦 joined the room. | 10:12:00 |
Erika Brito🏦 |  Download image.jpeg | 10:04:31 |
Erika Brito🏦 | Forwarded message from Erika Brito🏦 +1 CLIENTE SATISFEITO. INVESTIU SOMENTE $1000 REAIS RETORNO IMEDIATO 👆👆👆👆 | 10:04:31 |
Garga | In reply to Myracullu Consultoria : Suporte para Provedores ``#!/bin/sh -e # #### BRASIL ####
VL=ls -l /home/myra | grep teste.txt -c if ! [$VL -eq 0] then echo $VL exit 1 fi exit 0 `` Boa tarde , o script precisa fazer uma contagem desse arquivo e se ele existir imprimir na tela o valor da variável , porém não está funcionando. Alguma dica ? esse trecho abaixo
VL=ls -l /home/myra | grep teste.txt -c
if ! [$VL -eq 0]
then
Na realidade vc quer saber se existe algum arquivo ou diretório (ou symlink, ou fifo, ...) que tenha teste.txt no nome, pra isso vc pode usar o ls direto na condicional e vc redireciona o stdout pro /dev/null pra ele não imprimir nada
if ! ls /home/myra/*teste.txt* >/dev/null 2>&1; then
Agora, se vc busca um arquivo cujo o nome seja teste.txt apenas, pode seguir o conselho do Helio
if ! [ -f /home/myra/teste.txt ]; then | 11:05:24 |
Garga | aproveitando, caso algum dia vc precise compara se um número é *diferente* de outro, ao invés de usar
if ! [ $VL -eq 0 ]
Use
if [ $VL -ne 0 ]
Seu código fica mais limpo dessa forma, já que existe um operador pra diferente | 11:06:27 |
Myracullu Consultoria : Suporte para Provedores | In reply to garga esse trecho abaixo
VL=ls -l /home/myra | grep teste.txt -c
if ! [$VL -eq 0]
then
Na realidade vc quer saber se existe algum arquivo ou diretório (ou symlink, ou fifo, ...) que tenha teste.txt no nome, pra isso vc pode usar o ls direto na condicional e vc redireciona o stdout pro /dev/null pra ele não imprimir nada
if ! ls /home/myra/*teste.txt* >/dev/null 2>&1; then
Agora, se vc busca um arquivo cujo o nome seja teste.txt apenas, pode seguir o conselho do Helio
if ! [ -f /home/myra/teste.txt ]; then
Bom dia. Já resolvi. Obrigado | 11:06:33 |
28 Mar 2025 |
| Lucas Eduardo changed their profile picture. | 15:15:28 |
29 Mar 2025 |
| Dmitri joined the room. | 15:52:40 |
[helio@loureiro.eng.br/gandalf]> | Forwarded message from Nuno Nunes (누노 누네스) @waGNUx https://www.neowin.net/sponsored/the-ultimate-linux-shell-scripting-guide-worth-3599-is-now-a-free-download/#google_vignette | 21:28:07 |
30 Mar 2025 |
| Pirate joined the room. | 00:09:13 |
Nuno Nunes (누노 누네스) | In reply to [helio@loureiro.eng.br/gandalf]> Forwarded message from Nuno Nunes (누노 누네스) @waGNUx https://www.neowin.net/sponsored/the-ultimate-linux-shell-scripting-guide-worth-3599-is-now-a-free-download/#google_vignette https://neowin.tradepub.com/free/w_pacb230/prgm.cgi ate dia 9 de abril | 04:30:44 |
31 Mar 2025 |
| . . joined the room. | 05:53:24 |
| . . set a profile picture. | 05:53:25 |
. . | . | 05:53:23 |
| 🤓 joined the room. | 12:28:10 |
1 Apr 2025 |
| Dmitri changed their display name from D S to Dmitri. | 12:18:42 |
2 Apr 2025 |
| ⚔️gυ乇ᗪ𝐞ş⚔ joined the room. | 00:56:39 |
| Guilherme Gonçalves joined the room. | 01:02:54 |
3 Apr 2025 |
| Tiago Matos joined the room. | 01:45:53 |
9 Mar 2022 |
| Helio Loureiro set the history visibility to "world_readable". | 19:58:13 |
| Helio Loureiro set the room name to "Shell Script Brasil". | 19:58:13 |
| Room Avatar Renderer. | 19:58:39 |
10 Mar 2022 |
| thePi joined the room. | 01:31:39 |
thePi | Teste | 01:31:49 |
Helio Loureiro | !tg bridge -1001044493554 | 15:39:21 |
thePi | Adiciona o bot primeiro | 15:39:53 |
thePi | @telegram:t2bot.io | 15:40:06 |
Helio Loureiro |  Download image.png | 15:40:38 |