Posts by Incrivel Monstro Verde Cabelud • 317 points
17 posts
-
1
votes2
answers128
viewsA: Timer for a shell script command
You can use Kill -INT, which does the job of Ctrl+C # Roda o script de captura em background ./x.sh & # Aguarda 1 minuto (seconds) sleep 60 # Kill killall -INT airodump-ng Optionally, you can…
-
0
votes1
answer103
viewsA: import a txt file into mysql
It would take a few lines of your txt file to check, but you can use a script like: #!/bin/bash while IFS= read -r line do ip=$(echo "$line"|cut -f 1 -d ':') country=$(echo "$line"|cut -f 2 -d ':')…
-
0
votes2
answers388
viewsA: Shell Script Compare multiline variable values with string
You will need a loop to read the variables and compare them #!/bin/bash #valor da variável vem de 1 arquivo que contém as duas linhas #le o arquivo ambiente IFS=$' ' read -d '' -r -a LINES <…
-
0
votes1
answer44
viewsA: String set for a for loop using pipe (shell script)
You can use a temporary file for this. #!/bin/bash TEMP_FILE=/tmp/tabela for i in $(seq 1 30); do cat /dev/urandom | tr -cd 0-9 | head -c 8 ; echo ; done | sed…
-
0
votes2
answers126
viewsA: Format file . csv in bash
I modified a little, making a copy of the file and changing the copy. #!/bin/bash echo -e "Arquivo nao-estruturado: \c" read nome_arq cp $nome_arq $nome_arq"_clean" arq=$nome_arq"_clean" sed -i…
-
1
votes2
answers166
viewsA: What does the double-dash stand for in a Bash command?
Signify command end options. After double dash/hiffen only positional parameters are accepted. In your example, grep will search the string "-v" in all files in the directory. If you do not use "--"…
-
2
votes2
answers338
viewsA: How to pass the value of a variable to uppercase or minuscule?
You can use awk to do this. Here’s an example. Put the line that converts into your script before you test it. Then test with $VAR instead of $1 #!/bin/bash #$VAR recebe $1 convertido para…
bashanswered Incrivel Monstro Verde Cabelud 317 -
0
votes1
answer46
viewsA: Loop running only for first line shell script
Worked with small changes, basically in IFS and using var $query in TABLE #!/bin/bash IFS=' ' QUERYS=$(cat /tmp/querys.txt) for query in $QUERYS do TABELA=$(echo $query|awk '{print $4}') $(mysql…
shell-scriptanswered Incrivel Monstro Verde Cabelud 317 -
0
votes1
answer71
viewsA: Bash alias to create runtime script
use alias + Function: alias mksh='function __mksh() { touch $*; chmod +x $*; }; __mksh' you can even use several arguments such as: mksh file1 file2 file3
bashanswered Incrivel Monstro Verde Cabelud 317 -
1
votes4
answers249
viewsA: Delete multiple columns using awk
try: awk -v f=2 -v t=676 '{for(i=f;i<=t;i++) printf("%s%s",$i,(i==t)?"\n":OFS)}' solution aimed at: https://www.unix.com/shell-programming-and-scripting/35420-give-column-range-awk.html…
-
0
votes2
answers284
viewsA: Schedule Crontab task by script.sh
Do a simple test before, like,: grep -q licenca.sh /etc/crontab || echo "00 01 * * * retag /retag/licenca.sh" >> /etc/crontab If you do not find the string "licenca.sh" in the file, add. If it…
-
1
votes2
answers396
viewsA: How to create a shell script that puts an echo at the beginning of each line in a file
With sed is also possible: sed -i -e 's/^/echo \"/;s/$/ >> log\"/' arquivo
-
0
votes2
answers41
viewsA: I can’t change the value I want from a file through Shellscript
Can use awk -F: -v OFS=':' '$9 == "13" { $9 = "888" }1' arquivo if you want to write to a new file, use > newfile at the end of the command
shell-scriptanswered Incrivel Monstro Verde Cabelud 317 -
1
votes2
answers175
viewsA: Confirmation of site or host service status
You can use it like this: #!/bin/bash HTTP_CODE=$(curl -o relatorios.txt -L -s -w "%{http_code}" http://www.yoursite.com/pagina.html) if [ "$HTTP_CODE" == "200" ]; then echo "operando servico web"…
-
1
votes3
answers73
viewsA: Remove specific line of files on linux
Use sed -i to replace in the file itself: sed -i '/* * * * * root \/home\/linaro\/funcao4.sh/d' arquivo
-
1
votes3
answers538
viewsA: Replace a line from a bash script file
Use this sed option: sed '17s/string/newstring/' file where '17' is the row number to replace If you already want to exchange directly in the file, include the -i parameter…
bashanswered Incrivel Monstro Verde Cabelud 317 -
2
votes1
answer485
viewsA: LINUX - how to use a string as a delimiter in the cut command
With cut, I believe it is not possible, but you can use the awk: awk -F"string" '{print $1}' file