Most voted "bash" questions
Bash is a very popular shell (command interpreter). Using the commands provided by Bash itself (built-in Commands) we can perform a series of operations in sequence or create quite complex scripts/programs.
Learn more…291 questions
Sort by count of
-
0
votes2
answers68
viewsLinux running average
I need to take the average running time and consumption of CPU de 30 execuções of a program made in Python. I have to use the remote time of Linux. Like I’ve never worked with Linux before I’m…
-
0
votes1
answer52
viewsSyntax error in csh script
When I try to run the script, I get this error: $ ./install $ if: Expression Syntax. I’m trying to install the Altera Complete Design Suite 7.2, in the Debian GNU/Linux 7, Kernel Linux…
-
0
votes1
answer311
viewsPermission to shutdown now!
How do I give permission to execute the command shutdown to the user ? I am using OS Linux Mint 13.
-
0
votes1
answer325
viewsCount number of occurrences in a for in loop {Bash}
I have the following script #!/bin/bash for file in *.jpg; do convert $file -resize 1920x1080! -blur 0x8 alterado$file; echo "A Processar o ficheiro $file" done I want to do an echo with Processor…
-
0
votes3
answers280
viewsMake a shell script bash that extracts to a new file all names and nr of women whose number starts with "91"
Consider that there is a "file1.txt" file that you have for example: Name of the person;Sex;Postal code;Cell phone number;Brand of the Cell Phone ... How do I write a shell script bash that extracts…
-
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
answer65
viewsScript with mv Error: cannot move new_name to new_name/original Directory not Empty
Hello, I have the following function below, her goal is to check if the folder exists, and rule out, extract the file .tar.gz and rename. ssl_v="1.0.2g" ABI="armv6" # Clean then Unzip [ -d…
-
0
votes1
answer35
viewsrequest for support in optimization, fix shell command for mac
I am looking for the best way to optimize the following command shell in the Mac OSX, in order to fulfill the function that is intended which is basically to copy all files xx to the folder xx2:…
-
0
votes0
answers61
views -
0
votes3
answers541
viewsBash - Save errors in a variable
I’m running a bash script that saves error messages in a file. txt log, need to save the error messages in a variable now, follow example: LOG="/home/control/log.txt" exec 2>>$LOG tar -zcf…
-
0
votes2
answers138
viewsDownload multiple Curl pages at the same address without overwriting
I need to download this page several times, it returns a different result each time it is accessed: i="0" while [ $i -lt 10 ]; do curl -O http://httpbin.org/bytes/128 i=$[$i+1] done But each time…
-
0
votes1
answer41
viewsscript called once but turns two processes
I have here a script to test a function in the background. When I spin is launched two processes and I do not understand why. One stops at the "Sleep 20", and the other wheel eternally. #!/bin/bash…
-
0
votes0
answers138
viewsXfce terminal does not recognize ruby and Rails commands
Hello, when trying to run ruby or Rails commands on the linux terminal Manjaro error occurs stating that the command is not recognized. I tried to perform the same procedure I used for Ubuntu, but…
-
0
votes0
answers212
viewsHow to change environment variable path $HOME to another?
The intention is to load with you all "created or downloaded" files, and reassemble it in any Livecd distro, leaving it as the default directory. Note that, the essential in this logic of reasoning…
-
0
votes3
answers2121
viewsAdd line at the end of the file with the sed command
I am configuring a virtual machine to install JDK 7, Tomcat 7, Jboss EAP 7 and Postgresql. Follow the project on Github for anyone interested: cresol-enviroment-Vagrant. I’m at the part where you…
-
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
votes1
answer209
viewsDoubt with exercise in Shellscript
I would like some help to resolve these exercises: In the Ex4.1.sh script add the option to enter the word and file name directly from the command line this way: $ ./ex4.1.sh <palavra>…
-
0
votes0
answers529
viewsnpm | Installation dependency failure
My system: - Windows 10 - Bash on Ubuntu on Windows I’m new to bash usage. I installed nodejs, followed by npm and finally grunt. Everything worked well. I used the grunt no problem, but I started…
-
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
votes3
answers83
viewsHow can I display only the package names while being unpacked
The question that perhaps already have some answer, however I did not find. I’m kind of lost, I would say that a little confused even because what I’m asking I think I’ve done it in some…
-
0
votes0
answers91
viewsDuplicate paths in $PATH environment variable
I have noticed that the paths I add to $PATH in my .bashrc duplicates appear when I open tmux (multiplexer terminal): export PATH=$HOME/miniconda3/bin:$PATH export PATH=$PATH:$HOME/Devel/bin If I…
-
0
votes2
answers234
viewsHow to read a string within an array?
I would like to read a varchar field in a Mysql database, which contains several dates in the following format: "20171012 20171102 20171115 20171120 20171225" all into an array of the type, like…
-
0
votes1
answer450
viewsHow to send multiple folders using SSH (SCP)
I have a "deploy.sh" file that has the following command: scp -r ./public_html [email protected] -p 9922 But the command keeps giving error: No such file or directory But the…
-
0
votes2
answers54
viewsHow to run a bash file "mytest.sh" on a MAC without using ". /" alias and globally?
I have a file mytest.sh which will be distributed among other users (all with mac). I wanted to know what has to be done so that they can run the script of this file, from anywhere ( globally )…
-
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
votes0
answers75
viewsBash Shell - Script to get user-chosen URL’s
Good night, I have a question about a bash shell script that will return the URL’s present in a Reddit page, that is, in a subreddit. What I managed so far was to return the URL’s that are on a page…
-
0
votes1
answer123
viewsCron job that runs a bash script (which runs a python script) behaving differently than when executed manually
Hello.. I have a python script that plots two different graphs and that needs to be run daily to update these graphs on a website The data that is used by this script, is in a certain directory in…
-
0
votes1
answer73
viewsChoose how many lines you want to show in the output
I am trying to put a flag -n to be able to show in the output the number of lines desired by the user, having so far only been able to show the line number beside case "$1" in ## definir o…
-
0
votes2
answers1165
viewsScript to check if directory is empty
I’m knocking my head to create this script. I need a script, can be in bash or php even, check if a directory has some file inside, that is not another directory. This directory that I have to scan…
-
0
votes1
answer537
viewsHow to open and close a browser window programmatically using bash commands in Ubuntu 16.04?
I have a bash code that, at the end of some installations, should automatically open a browser window with a URL (myapp.com) passed as parameter. A php configuration page is displayed, confirming…
-
0
votes1
answer893
viewsHow to clone from a Bitbucket repository using bash code and passing the password as a parameter?
I have a bash code that creates a server instance in AWS. The last step of this process is to clone the project that is in the bitbucket.org. Usually what I do manually are these steps: cd…
-
0
votes1
answer708
viewsStart a virtualenv with file . bat
I got this . bat cd C:\Users\SERVIDOR-ARQUIVOS\Documents\workspace\email\.venv\Scripts activate.bat cd C:\Users\SERVIDOR-ARQUIVOS\Documents\workspace\email\src python manage.py (comando…
-
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
answer20
viewsOutput redirect
comando | tee -a saida.txt How do I redirect only part of the output of a command?
-
0
votes1
answer81
viewsHow to run Shell With PHP using bash compiler
I’d like to know how to run PHP in the Shell, using the Bash. I tried it this way but make a mistake: #/usr/bin/php <?php echo 'Olá Mundo'; ?>…
-
0
votes0
answers38
viewsHow can I call a.py program on a server within another local.py program?
I’ve been interacting with a server within a program I’m doing using the os.system() function as if I were using the console itself. os.system("ssh [email protected] 'comando a ser realizado'") For…
-
0
votes1
answer149
viewsExtract substring from a bash line with a Pattern
Good afternoon to all, I have a text file with several lines with fixed columns: 11Sala 1:4 FF The first column has the ID, and the second has the data I want to get (1:4), but when I have lines in…
-
0
votes1
answer36
viewsHow to do a git push to bitbucket programmatically using BASH on Ubuntu16.04?
I have a bash script running in Ubuntu 16.04 whose goal is to create a project (Folder) Expandable and then create that same repository in bitbucket and then push the content to the repository that…
-
0
votes3
answers1114
viewshow to commit a cloned repository?
Yesterday I created a repository on github and gave some commits, today on another machine I already cloned a repository and I’m trying to commit changes but I can’t. process... I’ve done so far $…
-
0
votes2
answers623
viewsRegular expression for dynamic URL
I have an html file with urls in this URL pattern: https://www.olympikus.com.br/tenis-olympikus-flower-415-feminino-cinza-D22-1131-010 The standard is protocolo://dominio/strig-dinâmica-000-0000-000…
-
0
votes1
answer107
viewsHow to reset Ubuntu bash password from windows 10?
I don’t remember my Ubuntu bash user password on Windows 10 how do I create a new password for my user?
-
0
votes2
answers131
viewsError of logica shell script
I want to print on the screen a message according to the current time of the day but it always falls on Is, what would be the mistake? It’s 1:00 and I don’t understand what the mistake is.…
-
0
votes1
answer69
viewsEditing file with shell script links
I have a file with 130 links to download via wget, all files are with the listed links such as:…
-
0
votes1
answer32
viewscPanel backup script moving files to wrong folder
I have this full cPanel backup script that works well: (https://github.com/pietromalerba/cPanel-Full-Backup-Script). I followed exactly the orientation settings, created two folders…
-
0
votes1
answer376
viewsBlock comments on bash script
I need to comment on a code block and found the following way it worked: <<COMENTÁRIO meus comentários aqui... ... COMENTÁRIO I wonder if this is the right way to do it, I read on a website…
-
0
votes1
answer485
viewsLINUX - how to use a string as a delimiter in the cut command
How do I use a string in the cut? command: cut -d"String" -f1 but he says it is only possible with a single character.
-
0
votes1
answer74
viewsHow to copy the largest folder file to another using bash shell?
Inside a directory with several subdirectories I can search all the files . py, see only which ones have datetime and show me only the largest of them. Using find, grep, ls and head, but when I try…
-
0
votes3
answers73
viewsRemove specific line of files on linux
I need to remove a particular line in a file crontab ex: * * * * * root /home/linaro/funcao1.sh * * * * * root /home/linaro/funcao3.sh * * * * * root /home/linaro/funcao4.sh * * * * * root…
-
0
votes1
answer34
viewsNext element of the loop
I’m trying to implement a commit search algorithm between two tags with the command git log tag1...tag2. For this I used the command git tag that returns me the tags of a repository. With this…