!KztHyqyRlIfASAkcPZ:matrix.org

Shell Script Brasil

935 Members
7 Servers

Load older messages


SenderMessageTime
23 Mar 2025
@emanresu3:matrix.orgemanresu3

e sim, o script ficaria melhor asim:

set -- /home/myra/*teste.txt*
if [ $# -ne 1 ]; then
  echo "$#"
  exit 1
esac
18:20:06
@emanresu3:matrix.orgemanresu3
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
@telegram_7442206749:t2bot.ioErika Brito🏦 joined the room.10:12:00
@telegram_7442206749:t2bot.ioErika Brito🏦image.jpeg
Download image.jpeg
10:04:31
@telegram_7442206749:t2bot.ioErika Brito🏦 Forwarded message from Erika Brito🏦
+1 CLIENTE SATISFEITO. INVESTIU SOMENTE $1000 REAIS RETORNO IMEDIATO 👆👆👆👆
10:04:31
@telegram_418076012:t2bot.ioGarga
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
@telegram_418076012:t2bot.ioGarga 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
@telegram_209117860:t2bot.ioMyracullu 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
@telegram_155706732:t2bot.ioLucas Eduardo changed their profile picture.15:15:28
29 Mar 2025
@telegram_7384165404:t2bot.ioDmitri joined the room.15:52:40
@telegram_64457589:t2bot.io[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
@telegram_5225905374:t2bot.ioPirate joined the room.00:09:13
@telegram_248334232:t2bot.ioNuno 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
@telegram_1647949986:t2bot.io. . joined the room.05:53:24
@telegram_1647949986:t2bot.io. . set a profile picture.05:53:25
@telegram_1647949986:t2bot.io. ..05:53:23
@telegram_8107561049:t2bot.io🤓 joined the room.12:28:10
1 Apr 2025
@telegram_7384165404:t2bot.ioDmitri changed their display name from D S to Dmitri.12:18:42
2 Apr 2025
@telegram_5369168648:t2bot.io⚔️gυ乇ᗪ𝐞ş⚔ joined the room.00:56:39
@telegram_1420304372:t2bot.ioGuilherme Gonçalves joined the room.01:02:54
3 Apr 2025
@telegram_1387761192:t2bot.ioTiago Matos joined the room.01:45:53
9 Mar 2022
@helioloureiro:matrix.orgHelio Loureiro set the history visibility to "world_readable".19:58:13
@helioloureiro:matrix.orgHelio Loureiro set the room name to "Shell Script Brasil".19:58:13
Room Avatar Renderer.19:58:39
10 Mar 2022
@nicolasb:matrix.lolispace.moethePi joined the room.01:31:39
@nicolasb:matrix.lolispace.moethePiTeste01:31:49
@helioloureiro:matrix.orgHelio Loureiro!tg bridge -100104449355415:39:21
@nicolasb:matrix.lolispace.moethePiAdiciona o bot primeiro15:39:53
@nicolasb:matrix.lolispace.moethePi@telegram:t2bot.io15:40:06
@helioloureiro:matrix.orgHelio Loureiroimage.png
Download image.png
15:40:38

Show newer messages


Back to Room ListRoom Version: 9