Most voted "shell-script" questions
Shell script is a scripting language
Learn more…262 questions
Sort by count of
-
3
votes2
answers1000
viewsHow to get the pid of a windows process right after the process is run
How to get the pid of a windows process right after the process is executed, similar to the command $! that retrieves the pid from the process that was executed needed in a way to grab that pid from…
-
3
votes2
answers284
viewsSchedule Crontab task by script.sh
I want to schedule the crontab through a script.sh. I tried to add the following line inside the script.sh: echo "00 01 * * * retag /retag/licenca.sh" >> /etc/crontab It worked, but he adds a…
-
2
votes1
answer123
viewsHow to make a find on GNU Linux bring some files and ignore others
How to make a find on GNU Linux bring all files from a folder, ignoring the files from a specific subdirectory.
-
2
votes2
answers106
viewsswap commands in the shell
The command python foo.py When called on the terminal, it runs the uploaded python file. Imagine that I have a python file that always needs to be called as follows: xvfb-run python foo.py to work.…
-
2
votes1
answer331
viewsComputer Date and Language Shell Script
Is there any shell script function that takes the date and time (time zone) and language that are configured on the computer?
-
2
votes2
answers254
viewsUnzipping files with space in name
I’m trying to unpack a large mass of files on linux and I’m trying to use a for that looks like this: for z in *.zip; do unzip $z ; done but I get the following message: unzip: cannot find or open…
-
2
votes2
answers58
viewsError using alias and read in Shellscript
I’m trying to create a command on. Ubuntu bashrc, however I’m having a problem, I’m trying to create a folder with the variable typed when calling the alias, but it’s giving error. When I open the…
-
2
votes1
answer208
viewsPrint array value in bash by PHP shell_exec
I have another script, but I simplified it for this to simulate the problem that persists. test sh. #!/bin/bash ARRAY=('like' 'a' 'stone') echo ${ARRAY[0]} In the file below, in another moment I…
-
2
votes2
answers186
viewsConvert File Names to Alphabet Letters
Convert File Names to Alphabet Letters For example, I have several image/photo files in a directory, and I want to pass these long names of the respective images in names designated by letters of…
-
2
votes1
answer504
viewsinsert bash commands into expect
Good evening guys, I have an activity to do that I needed to use Expect to remove user interaction in an SMTP communication. Only that in the body of the email I need to add the current date and the…
-
2
votes1
answer804
viewsHow to create Debian startup script by modifying environment variables
I need to elaborate a startup script that modifies the resolution that Debian puts by default. I currently have the following shell script that does the job: export…
-
2
votes1
answer199
viewsWrong return of ping command
Taking into account that the ${parameters} is an array that can contain valid IP addresses or not, I wrote the following code: for ((i=0; i<$#; i++)); do eval "arg=\${$i}" ping ${parameters[i]}…
-
2
votes1
answer472
viewsHow to sort a column of a file without ordering the rows?
I have a file that has three columns, and several rows. The second column is composed of numerical values, and I want to reorganize it, in ascending order, but without affecting the previous column…
-
2
votes3
answers507
viewsTransform date format DD/MM/YY into MM/DD/YY into Shell Script
The script reads the date of a . txt in DD/MM/YY format, and I need to convert it to MM/DD/YY format with Bash, Sed or AWK.
-
2
votes2
answers761
viewsStore paths containing directory with space in name
I have the following problem: I need you to store a path from an X directory in a variable in my script. The big problem is that one of the folders in this path contains space in the name and for…
-
2
votes1
answer72
viewsBackup and deploy with shell script
I have a productive environment for which I upload html, css etc. However, every time I upload a file I must first make a backup of existing occurrences. I’m trying to build a script that does the…
shell-scriptasked 8 years, 1 month ago Fábio Jânio 3,407 -
2
votes2
answers522
viewsInsert string in first column
I am breaking my head with something very simple, I need to insert a ";" (point and comma) after a Sort/Uniq in a file. As it returns the number of repeated lines, I need this return that is always…
-
2
votes2
answers1262
viewsHow to run mysql database using shell script if the base name has "-"
On the server there are some databases with the name modelo-submodelo (this is the name of the database, created with "-" same). When I execute a command like: mysqldump -h"$DBHOST" -u"$DBUSER"…
-
2
votes1
answer522
viewsCompare files from a directory with md5sum and shellscript
Good morning! I am studying shellscript and an exercise asks for a scan of files in the current directory and to calculate the md5 hashes. It also asks that, in case there are identical files by…
-
2
votes1
answer1671
viewsShell Script for file and directory localization
I wish someone could help me to create this script correctly, in this case it is to create a script that Oce type the name and directory of a file and then indicate whether it was located or not and…
-
2
votes2
answers1690
viewsManipulate Data with Date command
Expensive; I have a very simple problem, but I’m not finding a logic for it. I have a file with pre-fixed dates, example 2017-10-31, I would like each month change, this date be added with the…
shell-scriptasked 7 years ago user54154 473 -
2
votes1
answer64
viewsRetrieve arguments passed via ARGV in the terminal
I have a make file. Inside this make file, I call this file that has it: set -f; echo $1 | bc I want to recover function value in C for that Makefile file. Example: ./a.out "12 + 12" result: 24…
-
2
votes1
answer157
viewsHow to treat variable in bash?
I’m having a problem, I’m making a bash script to run using crontab, which synchronizes my SSD files, with the hard drive and Dropbox. Script: #!/bin/bash - PC_DIR="~/Programming"…
-
2
votes2
answers674
viewsTreat Curl return on Linux
I am mounting a shellscript and sends a json file to a webservice, the return is as follows: {"success":false,"errorCode":3,"message":"Authenticity Token invalido"} I am tempted, using Linux…
-
2
votes3
answers3476
viewsGrep with multiple parameters
I need to select the lines of a file that contains the characters | or \ diff -y ontem.csv hoje.csv | grep -e "|" -e "\" How to tell pro grep to return the lines it contains or a pipe | or a bar \…
-
2
votes2
answers109
viewsFind and Replace in bash
I need to find outdated lines in a csv file and replace them with new lines. These are the commands that find the lines that will be replaced(old) and that will replace(new). linhas_antigas=$(diff…
-
2
votes1
answer138
viewsEdit configuration file
I have a configuration file with several parameters, example: campo1=valor campo2=valor campo3= I would like to assign a value to campo3 with Shell Script. I tried to do with awk but I couldn’t. The…
-
2
votes2
answers83
viewsSort files in shell
I’m a beginner in programming and I’m stuck in a code here. Through shell I have to search inside directories and subdirectories all files that are of format .py and have the bookstore datetime…
shell-scriptasked 6 years, 1 month ago Danjmp 21 -
2
votes2
answers210
viewsHow to change the file extension recursively in GNU/Linux?
I’m trying to get all the files .sql of my project and change the extension to .md. I’ve been able to do this, however, the files are being moved to the system root, which is the path where the…
-
2
votes1
answer15108
viewsHow to declare a variable in . BAT ("shell")?
I’m starting to mess with file. BAT, and I created a command line. Example: ping <nome do computador> Below it would show me if it is online, would look like this: ping computador_1 But I…
-
2
votes1
answer142
viewsRegular Expression is correct but does not enter if
I wonder why my code isn’t getting into this if more internal. I tested regex for some websites and it’s working. I tested with this value: nucepe-2018-pc-pi-perito-criminal-informatica-prova.pdf.…
-
2
votes2
answers1544
viewsScript . sh to run a python script from within Cron
Good morning. I’m having a problem with a python program I did. What happens is that when I run my program from the command line with this command it works normal : python3…
-
2
votes3
answers3774
viewsWrite text to Shell Script
I am making a Shell Script, and I have to record a lot of lines in a single file, how can I do this more automatically? 'Cause I started doing it in a very manual way: echo "primeira linha do…
-
2
votes2
answers201
viewsswitch case in bash
Man switch case is not working properly: while getopts "hvo:umsf" OPTION do case $OPTION in i) instalarSniper ;; h) help ;; s) simular ;; d) adicionais ;; ?) echo "Parametros incorretos, digite -h…
-
2
votes2
answers454
viewsHow to create a script to rename files on Ubuntu 18?
I have a folder called baixar-nanatsu and inside the folder I have several videos. I wanted to change the name of the videos via bash or shell script automatically, only I have no idea how it does.…
-
2
votes2
answers186
viewsUnexpected output when printing substring
I’m doing a file search in a given directory and printing its respective path. find ./ -exec sh -c "echo $(dirname "{}")" \; Output: ./algo/desse/tipo Since in some cases this path is a little big,…
-
2
votes1
answer102
viewsFind via SSH on multiple servers
One of my activities in the company I work with is to check Jvms log when we have errors in the application. The way this check is done is through SSH (we have a "tunnel" configured through VPN…
-
2
votes1
answer123
viewsAlias created in shell-script does not work
I’m trying to create a alias using a shell-script, but at the end of the execution the alias disappears. #!/bin/sh echo "Configurando ambiente..."; mkdir -p ~/.dna alias teste="node…
-
2
votes1
answer79
viewsHow do I pass an array as an argument in PHP and receive all the data in the shell?
Example: <?php $param=array(valor, valor2, valor3); $return = shell_exec("sh teste.sh $param"); echo "<pre>$return</pre>"; ?> Shell script: #!/bin/bash param=$1 echo $param That…
-
2
votes1
answer187
viewsHow to print vector formatted in Shell?
I’m trying to get a string and change only one of its values, and that’s easy using vectors. However, when printing the string, the vector leaves without formatting, I have tried to print it with…
-
2
votes1
answer91
viewsWhat’s the difference between SEQ and FOR I IN in shell script
I started studying shell script recently and gave me 2 examples, and I would like to know the difference of the commands, when it is better to use one or the other. The example was seq 1 5| and the…
-
2
votes1
answer54
viewsReceive 12 elements and separate them into 3 lists
I need to receive three lists generated in the shell to process in Python: l1=4 3 2 1 l2=2 1 3 4 l3=1 2 3 4 In the shell script step this way: python3 orth_median.py ${o_l1[*]} ${o_l2[*]} ${o_l3[*]}…
-
2
votes1
answer133
viewsHow to remove part of the name of all files in a folder via CMD/Powershell
I need to standardize the name of all the files in a folder, considering that the files already have a pattern at the beginning of their name up to the 8th character, being only necessary to demote…
-
2
votes1
answer167
viewsShell Script to calculate average runtime
I need to perform the same command 10 times and view the average run time. I did the script below, but it always returns the same output, zero, see print below. Could you help me find the error?…
-
1
votes1
answer298
viewsShellscript command cd
Which command do I use to go straight to folder login without having to put my name example cd home/leonardovillela.?
-
1
votes1
answer62
viewsClasspath of my shell script failed to find a particular jar
I have a shell script that executes the following instructions: #!/bin/bash java -Dcom.sun.management.jmxremote -classpath .:lib/* br.com.governa.admin.sincronizador.negocio.Sincronizador…
-
1
votes3
answers8609
viewsRun a Shell Script with double click on Ubuntu
I have a program in Shell, it does the installation and configuration of some programs on Ubuntu, I wanted to know how to compile or make it run when the user double click on it, yesterday had found…
-
1
votes2
answers783
viewsHow to pass a . sh file as parameter to a C code?
I need to pass a file with extension . sh . I have tried it as follows and the value that is read from the file is wrong: . /program . /file.sh How do I get this argument through? Do I need to add…
-
1
votes0
answers38
viewsExtract emoticons from text file with shell script and regular expressions
I want to 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 the sum…
shell-scriptasked 9 years ago user35473 11 -
1
votes2
answers1858
viewsShell script Sed read one file and write to another only on the first occurrence of a string
Good afternoon, I am trying to read from an X file and write to a Y file when a specific String appears. But I only want to include it once. Example I’m trying to make: sed -i '/, pasta/r teste.txt'…