Most voted "shell-script" questions
Shell script is a scripting language
Learn more…262 questions
Sort by count of
-
1
votes2
answers1005
viewsExtract only the name of a file from the full path
I want to make a shell script that gets a filename with its full path, for example /home/42/arquivoEscolhido.txt, and extract only the file name (arquivoEscolhido.txt), that in case it would be all…
-
1
votes1
answer191
viewsShell Script - "split" em for
I made a query that imputes the result in a file .txt in this mold: -----id--------action H000tg6b JOB H000oi8a JOB H00067w JOB I need to make a for to go through that file and use the two pieces of…
-
1
votes1
answer1137
viewsRemove character in Shell Script
all right? I’m making a script to read a log on my server to pick up just a few parts that interest me and play in a . csv. The script is very simple, follow: #!/bin/bash export…
-
1
votes1
answer443
viewsShell Script for copying renamed file structure to target
I would like to copy a folder structure already renaming the files to their destination by placing in front of the name a text previously informed by the user. But I’m having trouble copying renamed…
-
1
votes1
answer167
viewsAdd bash output to text
Well, I’m trying to create a text log, with the days and times my script was executed. Only, for example: when I use echo 10/03 - 13:20 >> log.txt it overwrites there in the text file by…
-
1
votes1
answer43
viewsProblem with case in script
Someone explains me why my script is only returning the "Error option"? #!/bin/bash #==========================# DATA=$(date +%T) #Vai mostrar a hora com os mins CORTE=$(date +%k) #Vai mostrar…
-
1
votes2
answers312
viewsHow to make my script run with two clicks a command that contains sudo?
I have a very simple script, similar to this: #!/bin/bash #Seleciono o diretório onde se encontra o arquivo para execução cd '/home/vmi/Área de Trabalho/TesteComandosNoLinux' #Executo meu software…
-
1
votes0
answers33
viewsADB Swipe mac/Linux invalid "Error: Invalid Arguments for command: Swipe"
Boas, I used a script that runs all commands of a txt file and only get the error "Error: Invalid Arguments for command: Swipe" when running with the script adb shell input all work. I know it’s not…
shell-scriptasked 5 years, 11 months ago Bruno Daniel 11 -
1
votes1
answer168
viewsBash write output in terminal and file
I am creating a script and need the outputs to be shown in the terminal, but also saved in a file #!/bin/bash echo "Olá Mundo" and I am redirecting the output to the file as follows ./teste.sh >…
-
1
votes1
answer32
viewsVariable running on its own
I am trying to create a variable that I will only use when I want to create a folder. But this same variable is creating this folder before the IF condition and the READ condition are executed.…
-
1
votes0
answers34
viewsHow to set the number of times to run Speedtest via PHP
Hello, I’m trying to run Speedtest on a server via PHP, I’ve installed the necessary on the server to be able to do this via Terminal on Linux, and I’ve also managed to run this test via Web access…
-
1
votes0
answers50
viewsIs it possible that a script knows where it was called?
I have a script.sh and I wonder if there’s any way he could know where he was called. ex: comando=$(existe algum comando pra isso?) variavel=$AlgumaVariavelDeAmbienteTalvez if [[ $comando == "x" ]];…
-
1
votes1
answer372
viewsHow to assign a variable the sed command with formatting? Shellscript
I’m having a problem making a program to exchange the first number for X, because even if it works, the variable does not receive the value permanently: VAR="oi 200 20 10" VAR= echo "$VAR" | sed -r…
-
1
votes1
answer95
viewsReplace columns of a row when another column starts with a specific word
I need to replace a letter from a column every time it finds a specific word in the file. Example: In the lines below, whenever you find the word PEDRO in a row in column 4, I have to replace "P"…
-
1
votes1
answer55
viewsCreate file from shell
I have a code that I created, and I need it to create a.txt file after the execution that I sent, but it is not doing. Follow code to better understand, I appreciate the help. #!/usr/bin/env bash…
shell-scriptasked 4 years, 8 months ago Igor Pompeo 37 -
1
votes1
answer94
viewsHow to create a sequence of files whose names come from a numerical sequence with predetermined intervals?
I need to create a sequence of files. Ex :1.log, 2.log, 3.log, 4.log and so on. I need to define the initial value and the final value, then it creates for me inside the desired folder. Below is the…
shell-scriptasked 5 years, 3 months ago Ricardo JM Sistemas 11 -
1
votes1
answer161
viewsDialog progress bar (Shell Script)
I would like to create a progress bar for my backup script. The problem is that the rsync command (which is inside the loop) generates duplicate (unnecessary) lines that increase the size of the log…
-
1
votes1
answer44
viewsError in logic to replace all phrases within an x file using Bash Shell Script
How can I replace all the same phrases within a file, using Bash Shell Script, when receiving the value to be replaced from a variable? 1 - How I would like - but it doesn’t work.:…
-
1
votes1
answer94
viewsLoop through the lines of a file and print parts of it in sequence
I have a text file that has several lines separated by two points. See for example: teste1:testee1 teste2:testee2 teste:testeeee Using a loop for, I’m trying to get the script to print on the screen…
-
1
votes0
answers50
viewsHow do I make generic shellscript commands for a program installation script?
How do I get commands to accept all possibilities in the code? (Generic) I am trying to make an automation script to install all the programs I regularly use in Ubuntu 20.04. In this case I try to…
-
0
votes2
answers199
viewsHow to check if a provider is on . ssh/known_hosts?
I have a script that synchronizes git repositories. If the repository has never been synchronized, directories are created. Eventually, when a repository is added, the server serving the repository…
-
0
votes1
answer622
viewsFolder monitoring on Linux
I could use some help. I need to assemble a shell script monitor 4 folders where each one receives a file with template different from the other. I need that when the file arrives an e-mail be sent…
-
0
votes3
answers292
viewsValidate ZIP code in Shell-Script
I’m entering this world of regular expressions, I’m having a doubt, I read about metacharacters, etc. Well, I’m trying to validate a zip code and I’m using the following command and I’m not getting…
-
0
votes2
answers3751
viewsHow to run scripts on Centos startup?
Good afternoon, how do I run a script in Centos 6.5? I’m running into /etc/rc.local /etc/rc.d/rc.local and is not loading the commands: sh /etc/init.d/script the command works outside the script.…
-
0
votes1
answer34
viewsProblem with upstart script
I’m trying to start my application in boot, but I’m not getting...the script in upstart calls another script, I’m not able to even know if the 2nd script is being called, follow the 2 scripts: 1st…
-
0
votes1
answer851
viewsExtract information from a text file with shell script and regular expressions
I want to make a script with Shell script that extracts from a text file emoticons, for example ;), :), :3, :(, xD and also count the emoticons of each sentence. A sentence is declared positive if…
shell-scriptasked 9 years, 4 months ago user35473 11 -
0
votes1
answer121
viewsProblems inserting commands into bashrc via script
I am trying to insert commands in bashrc via script. I turn the remote source powerpyenv.sh # powerpyenv.sh echo '### Added by pyenv' >> teste echo 'export PATH="$HOME/.pyenv/bin:$PATH"'…
-
0
votes1
answer311
viewsHow to protect upload php files against shell script
How can I protect sending php files against shell script, knowing that I only accept one type of extension.
-
0
votes2
answers537
viewsReplace files with sed
Hi, I have a problem I need to solve. I have a file that should be inserted exactly one column of another file, I’m trying as follows: cat $1 | cut -d ',' -f2 | tr "/" "-" | awk -F "-" '{print…
-
0
votes1
answer397
viewsError in passing parameter to a Shell Script
I am creating a script to take some images in the folder and with that generate another image, I am using Imagemagick, but the problem I am having is in passing one of the parameters of this script…
-
0
votes2
answers2044
viewsHow to get a part of a file name in shell script?
I have a file that has the format nome1-nome2-0.0.0.0.war, and through the shell wanted to take the version (0.0.0.0) and save it in a variable and then use it to create a directory. Obs.: The…
shell-scriptasked 8 years ago RebeccaMM 91 -
0
votes2
answers192
viewsGenerating a file that is output from a command only if a condition is met
Be the command: top -o %MEM -b > file.txt I would like you to file.txt only the values that are between two time periods, for example: between 07 April 2017 07h and 07 April 2017 12h. Is it…
-
0
votes1
answer974
viewsPG_DUMP via shell_exec returns "no password supplied"
I successfully execute the following command from the terminal: pg_dump -d teste -h 127.0.0.1 -p 5432 -U postgres -w -f /home/william/pgsql/17032701.backup However, when I execute the command by…
-
0
votes2
answers158
viewsMy shell script does not list all user processes
Why doesn’t my code list all user processes? I made a script to delete a user’s processes, it’s exercise... Good basically made a whoami and adiquiri in a variable, after that made a ps -aux | egrep…
-
0
votes1
answer71
viewsHelp with script tracing routes
I made a script that plots the route of a given IP, but with the while going up to 50, even if the connection has a jump of 8 routes, it will count up to 50, as I do to stop the while when finishing…
shell-scriptasked 7 years, 10 months ago st0rm 1 -
0
votes1
answer53
viewsShell: Draw file whose name contains blank space
Using shell script, I am creating a file script.sh that automates some tasks for me. In it I need to draw a file from the current directory to perform some tasks. I’m drawing the file with the…
shell-scriptasked 7 years, 11 months ago eightShirt 649 -
0
votes1
answer973
viewsConnect via SSH to another machine and run script
I am automating tasks and I am new in Python, so I would like your help because I need to run a Shell script on another machine and this command I need to give inside a Python code. I thought I’d…
-
0
votes3
answers2285
viewsHow to get the local ip in shell-script?
I’m making a script that needs the machine IP on the network, tried several ways unsuccessfully until I figured out a way: ip="`ip addr show | grep global | grep -oE…
-
0
votes0
answers47
viewsSearch only a value via shell script
Galley, I am creating a script to fetch a value, however, within the BDD there are repeated values and I would like to search only one of each. For example, there are several units for each state,…
-
0
votes1
answer257
viewsDatabase control (Mysql) in production environment
For a good part of my project I came working with git archive on a local server, (Debian 7), this week I migrated to gitlab, without any complication in the change, I changed only for portability,…
-
0
votes2
answers830
viewsFilter number of characters with SED or grep
I have a file with strings I need at first filter for example only lines that has 5 characters And in a second moment filter only those that have at least 2 characters repeated together Example:…
-
0
votes0
answers212
viewscommand not found
One more newbie question echo "Enter an integer number" read int checkNum=$(( int % 2 )) if [$checkNum -eq '0' ]; then echo "the number is even" else echo "the number is odd" fi Error when I enter…
-
0
votes1
answer180
viewsHow to enable autocomplete resource for shell script?
I would like my shell script options to be presented or autocompleted by pressing TAB, just like commands like aptitude or yum. How to enable autocomplete resource for shell script?
-
0
votes3
answers259
viewsHow to get response from 'apt remove' via shell_exec with PHP or Python?
With the shell_exec command I can get an answer if the result of the executed command is a single text: shel_exec('dpkg -l > list-softwares-dpkg.txt'); How to have the answer (in PHP or Python,…
-
0
votes1
answer86
viewswhile read does not work in Unix shell script
I’m writing a script and using while read twice he makes the 1 only once: un=$(echo $LOGNAME | tr '[A-Z]' '[a-z]') grep -v '^#' nodeteste.txt > auxiliar.txt while read line do ssh "$un@$line"…
-
0
votes1
answer81
viewsMy Shell script does not work "word Unexpected (expecting "in")"
I have no experience with Shell Script, and I can’t figure out what the problem is with my code. #!/bin/bash echo 'Deseja alterar a data e a hora deste computador (S/N) ?' read dataHoras if…
-
0
votes1
answer445
viewsHow to get the runtime of a program with shell script?
I am creating a basic script in which I would like to take the runtime of a program each time it is called in the script. #!/bin/bash for i in {1..15} do echo "Execucao $i" time ./meu_programa >…
-
0
votes1
answer242
viewsTreat special characters
I am treating the CURL return with SED, but as the information I receive but sometimes has the character / causes an error in the SED syntax. TOKEN=$(curl --silent $URL | awk -F '"' '/content/…
-
0
votes1
answer75
viewsGet the latest version of Mozilla Firefox by script
I was making a script that searches for the latest version of Mozilla Firefox in the URL #!/bin/bash base_url="https://download-installer.cdn.mozilla.net/pub/firefox/releases/"…
shell-scriptasked 7 years ago dark777 611 -
0
votes0
answers123
viewsTerminate ssh remote connection
I have the following script that opens a remote connection on the terminal: xterm -e ssh -t user@IP -p porta "cd pasta && bash script.sh && exit ; bash" How to get the connection…