Most voted "shell-script" questions
Shell script is a scripting language
Learn more…262 questions
Sort by count of
-
1
votes2
answers2307
viewsDelete all lines that have a specific string
I would like to delete all lines that have the string Excluído, searching from one specific string to the end of another. Example: <p class="FolderPath"> <table class="DiffTable">…
-
1
votes1
answer287
viewsHow to recover a deleted file by "rm" command?
I deleted a file by accident via the command rm. Is there any way to get it back?
-
1
votes1
answer36
viewsUnderline between two variables
I have the following code in a file . sh: echo "$pasta/Dados/$MA/$ano\_$mes/$tabela" With all variables set correctly. However, running the script, echo results in…
-
1
votes1
answer51
viewsSsh connection between computers
How to make a connection via ssh between a local pc and a server, with key authentication method.
-
1
votes2
answers412
viewsHow to send the result of a query by e-mail SHELL SCRIPT
I have the following appointment: #!/bin/bash db="bats"; table="promotion"; dbHost="192.168.0.246"; dbUser="root"; dbPass="root"; result=`mysql -h $dbHost --user=$dbUser --password=$dbPass…
-
1
votes2
answers174
viewsHow to send commands to the ruby interpreter from a Shell Script?
This is more out of curiosity... I’ve seen some examples of what I want to do, but in Perl. I tried to find a way to do the same in Ruby, but to no avail. I want a function to generate an MD5 hash…
-
1
votes1
answer309
viewsShell Script - Refresh page every 5 minutes
I need to update a web page (e.g., www.google.com) every 5 seconds because I have no idea how to do this script. someone can help me ? thank you
-
1
votes0
answers66
viewsHow to compile a project with Android.Mk through a script.sh?
I have a simple project with native code and am using manual command to compile /workspace/android-ndk-r11c/ndk-build TARGET_PLATFORM=android-14 TARGET_ARCH_ABI=armeabi NDK_PROJECT_PATH=.. In my…
-
1
votes2
answers1282
viewsShell/Bash - Script continues before finishing the line that is running
I have a shell/bash script that works perfectly to make backups, the problem is that I have large files that are giving problems in the execution of the script. The script has to compress the file…
-
1
votes1
answer421
viewsGet JSON values using Shell script
I need to list the values of the number and url fields using the json shell script below: [{ "numero": "001", "local": "brasil", "url": "http://brasil.com.br", "ipv4": "10.10.0.1" }] I’m wearing…
-
1
votes3
answers242
viewstable html shellscript
Guys, anyone who knows shellscript know how to create this requested script in the image below? I’m doing some exercises with the theme, and that kind of got me.…
-
1
votes1
answer392
viewsHow to list all files in ". ts" format of folders and subfolders to be converted to ". avi"?
I found a shell-script and modified it to meet my need and stayed like this: #!/bin/bash [ "$1" ] && cd "$1" ls -1 *.TS [ "$?" -ne 0 ] && echo 'Sem arquivos TS nesse diretório'…
-
1
votes1
answer107
viewsRoot permission to change date and time
I would like to know how to get my script to be allowed to change the date and time of the system without asking to enter the root password?
-
1
votes1
answer324
viewsScript for GIT update
I have a question and I don’t know how to fix it. The following happens, I created a script in sh called atualiza.sh inside it I have the following code. git add . git commit -m"atualiza rotina" git…
-
1
votes1
answer431
viewsWhat is the meaning of the symbol ":" and "?
The example I don’t quite understand is: cut -d : -f /etc/passwd | tr : \\t What do the two dots mean : and the two bars \\?
shell-scriptasked 7 years, 11 months ago xsolon 11 -
1
votes1
answer75
viewsbash program shows no data output
Good afternoon, I program in C and it’s the first time I’m programming in Bash (shell-script). I did some functions in bash, learned to call and created an interactive menu with the user, my program…
-
1
votes3
answers1757
viewsProblem creating script . sh to enter a directory
I am creating a script. sh that the first step is to enter a directory. 1. #!/bin/bash cd /home/salariosbrasil/consulta-ninja #git pull pwd this directory exists and yet the cd doesn’t work.. but if…
-
1
votes1
answer52
viewsWhat command is being misused in this script?
Whenever I run the script, the error message appears saying that the grep was used in the wrong way, which is wrong in the script ? Code: #!/bin/bash read $ALVO RESULTADO=$(ps -A | grep $ALVO)…
shell-scriptasked 7 years, 8 months ago user62320 -
1
votes2
answers351
viewsUse of Uniq
I have been researching without much success, something that in theory I believe is quite simple, however I did not find the correct command. I have a LOG file with a lot of information, but certain…
-
1
votes1
answer110
viewsScript help for tracing routes
I am creating a script similar to tracerouce, when I type an IP it plots the route to arrive at the final destination, but when the route reaches the destination, the while still continues, as I…
shell-scriptasked 7 years, 6 months ago user75733 -
1
votes2
answers480
viewsDeleting lines only if any cell in the worksheet is empty (using a script)
I have a spreadsheet from Calc (libreoffice)/Excel (actually it’s a text file that I opened as a spreadsheet for easy viewing) that contains some blank cells (not the entire line): I would like it…
-
1
votes0
answers237
viewsLinux script to e-mail the result of the find command
I need a help in a script to send a result by email to a search (find) and run every day at 8:00 am without using contrab on linux
-
1
votes2
answers878
viewsSubtract shellscript input argument value
I have the script below that prints on the screen the even numbers of 1 until the input argument. #!/bin/bash for i in $(seq 1 ($1)); do if [ $(($i % 2)) -eq 0 ] then echo "$i \c" fi done For…
-
1
votes1
answer147
viewsSlow bash script
I use a bash script to translate words from other languages into Portuguese. It always worked very well, but from a few days to here became extremely slow, to the point that I could not use it. some…
-
1
votes3
answers102
viewsReplace command output with a custom message
I am creating a script where at the end of it I run a command that displays a very large output of information. Is it possible to override this output? That is, instead of showing the default output…
-
1
votes1
answer31
viewsEach round loop var exchange
I am developing a shell system that has a form to add some fields. Quantity Product Valorunitario etc... I need every time the loop changes a variable, so I call it in the form! In the case is the…
-
1
votes1
answer390
viewsHow to create a Script inside a program in the terminal?
I’m looking to develop a script to automate some repetitive tasks I’ve been doing on the terminal. However. I can only create Scripts for Commands directly in the terminal, not for commands within…
-
1
votes1
answer3365
viewsWrite linux bash exits to a file
I need to do some tests on the linux command line, but doing all the tests is very time consuming, someone can help me, if you have, to write code in shell script to run all the tests, and record…
-
1
votes1
answer147
viewsShow only lines that appear more than x times. (shell script)
I am analyzing a log file and I wanted to filter only lines that appear more than 10 times inside the file. Only I’m not finding a way to make this filter.…
-
1
votes2
answers466
viewsCheck empty directories and pick up command output
I own a folder called work and inside it I have 2 folders: p1 and p2. How can I know if the folders p1 and p2 are empty ? I have the following command find . -type f -printf "%T@ %p\n" | sort -nr |…
-
1
votes1
answer143
viewsList file excluding first letter
I have a file called 1arquivo and I list him normally with the command ls. How can I use ls deleting the first letter to return me only arquivo. It has to be a generic solution because I will have…
-
1
votes0
answers91
viewssyntax error near Unexpected token `fi'
I’m new and I’m having trouble with the script below: echo "Enter an A, B or C" read letter if [[ $letter == "A" || $letter == "a" ]]; then echo "this is A" elif [[ $input == "B" || $input == "b" ];…
-
1
votes2
answers8165
viewsShell Bash, How to pass given from Shel as parameter
i need to run a file file1.sh, but in addition I need to take the data that comes after it, for example: file 1.sh 171.55.8.45, this ip that comes after, in the same line of the file, before…
-
1
votes1
answer146
viewsFlag at command line bash shell
I’m trying to put a flag that can sort or shuffle output, but I could only do that in code and intended it to work when you put the flag in the command to run the file, for example. /bash.sh -r.…
-
1
votes1
answer632
viewsCompare two files using Shellscript
I have a series of data collectors connected to a service. This service is provided by third parties and I do not have "admin" access to create queries as my interest. The only way to know if these…
shell-scriptasked 6 years, 8 months ago Brian Carvalho 11 -
1
votes3
answers99
viewsRun Shell Script by checking the 32bit or 64bit system architecture
How can I make a script that checks the system architecture and so it would execute the commands for the appropriate architecture, for example: if 32bit; then comandos para 32 bits else comandos…
shell-scriptasked 6 years, 7 months ago Miguel Silva 491 -
1
votes1
answer101
viewsCommand to Check if a software is installed on Ubuntu
Script that checks if a software is installed on Ubuntu. If installed, continue with the command sequence. if you do not ask if the user wants to install it anyway Example: if (programa1=Instalado,…
shell-scriptasked 6 years, 6 months ago Miguel Silva 491 -
1
votes3
answers238
viewsRemove all after ? in file name
Hello! I’m trying to rename a large amount of files on linux, but I’m not getting the command right. The case is as follows: I have several files inside a directory and its subdirectories that have…
-
1
votes2
answers50
viewsAdd . html extension at the end of all links in multiple files (with Shell Script)
Hello. I have a lot of HTML files that have links in the following format: http://localhost:8080/tag:alguma_coisa and I need to add the extension .html to these links so that they stay like this:…
-
1
votes2
answers54
viewsUnexpected exit
I am running this command to remove repeated lines from a file: cat arquivo.csv | (read;echo "$REPLY"; sort) | uniq > arquivo.csv But when I look at the file, it’s blank instead of just the lines…
-
1
votes1
answer82
viewsHow to create a ZIP file in Shell?
How do I create a ZIP file in Shell with the files of today’s date? The files are all in the same directory.
-
1
votes3
answers56
viewsMass collection of information from files
I intend to collect ctime, atime, mtime and crtime from a considerable mass of files. I have assembled the following script as a partial solution: sudo debugfs -R 'stat <1055890>'…
-
1
votes1
answer105
viewsWhy can’t nohup accept for loop?
I have this code inside a file called test.sh When I try to execute nohup ./teste.sh & he makes that mistake. Someone can explain to me ? ./test.sh: 9: . /test.sh: Syntax error: Bad for loop…
-
1
votes1
answer203
viewsHow to redirect the entire bash script within the script itself?
I need to throw his output into a file instead of playing on the default output which is the screen but without me having to spell it out with the command >> in the terminal, I want the script…
-
1
votes1
answer174
viewsProblem running a shell script using Zenity. Message: Gtk-Message: Gtkdialog Mapped without a Transient Parent. This is discouraged
When I execute script sh. via shell linux, appears this message: Gtk-Message: Gtkdialog Mapped without a Transient Parent. This is discouraged. How do I resolve this issue? #!/bin/bash get_url () {…
-
1
votes2
answers183
viewsHow to get the Exit code from a command block
Suppose I have the following commands in a script susd systemctl status firewalld If I look at the exit code through echo $? it returns 0 because the last command was executed successfully, but how…
-
1
votes1
answer133
viewsHow to pass variable to PHP file in Shell Script
how can I pass a variable to a php file in a shell script, I’m trying to do this way below, without success. php -f complete.php?login=$1
-
1
votes1
answer115
viewsHow to pass vector as argument in shell script?
I would like to pass a JSON-style vector as an argument for a script. Example : #!/bin/bash vetor[]=$1 echo ${vetor[*]} i=0 for nomes in ${vetor[*]} do i=$(($i+1)) echo "Nome $i é $nomes" done And I…
-
1
votes1
answer415
viewsHow to insert a query value into a variable in the Shell Script?
I have a JSON in an archive nomes.txt. the JSON is : {"p": { "nome": ["josé","Maria", "carlos","Artur"] }} I want to play the value of his query in a variable. Show result works fine : #!/bin/bash…
-
1
votes1
answer628
viewsHow to get the size of a string array in the shell script?
I have a string that I pass as a parameter, for example : "2,3,4,5" To pick up every item of it I make : #!/bin/bash for ((i=1; i<=4; i++)) do echo "$1" | cut -d "," -f $i done But I would like…