Questions tagged as 'bash'

3
answers

Check if variable is a positive integer

To check if a variable is a positive integer , I'm resorting to a regular expression: #!/bin/bash id="$1" regNumTest='^[0-9]+$' if ! [[ "$id" =~ $regNumTest ]]; then echo "Parâmetro #1 deverá ser um inteiro!" exit 0 fi Wil...
asked by 25.03.2015 / 16:08
2
answers

Bash, know what directory is running

How do I get the directory path where the script in bash is located, from inside the script itself? #!/bin/bash MINHADIR="caminho/para/onde/estou" # apanhar a diretoria onde estou atualmente     
asked by 13.04.2015 / 23:52
3
answers

Executing command with another user inside a shell script

I have a shell script that I need to execute some commands with a linux user, and some other commands with another user. Something like this: #!/bin/bash echo 'rodando com usuário A' comando1 comando2 comando3 echo 'Rodando co...
asked by 23.05.2014 / 21:54
2
answers

How to create an alias to execute multiple commands with git?

I would like to know how to create an alias for git that runs the following commands: git add (all modified files) git commit (including a message) git push I tried the following configuration in gitconfig: [alias] upl = !git add...
asked by 08.02.2017 / 15:40
1
answer

Select database record for variable

The code below aims to select a database record and save it in a variable for later use of the data: #!/bin/bash dbName='basedados' dbUser='utilizador' dbPass='password' row=$(echo "select file_id, file from catalogue__pdf_file WHERE is_conv...
asked by 31.03.2015 / 21:37
3
answers

Bash - Mysql Backups

I set up the script below to perform backups of three Mysql databases. I wonder if it's correct. #VARIAVEIS DATE='date +%Y%m%d-%H%M' HOSTNAME1="xxxxx" HOSTNAME2="yyyyy" HOSTNAME3="zzzzz" USER='xyzedmar' PASSWORD='xyz2' DATABASE1='xxxxx' DATABA...
asked by 07.12.2015 / 22:51
3
answers

Prevent the script from following symbolic links

With the script below, a search is made to all the existing properties in the indicated directory in order to obtain the email addresses associated with each hosting: #!/bin/bash # Scan All available email account addresses # for homedir unde...
asked by 22.12.2014 / 13:10
1
answer

CMD, PowerShell, Bash - What's the difference?

There are differences between them, which ones? I speak Ubuntu Bash. I'm curious because to me they seem to do the same thing!     
asked by 07.08.2016 / 21:08
2
answers

What is a binary operator

I made a code in bash: #!/bin/bash echo "Digite o arquivo: " read ARQUIVO PROCURA=$(find /home/gabriel -name $ARQUIVO) test $PROCURA -e & echo "O arquivo '$ARQUIVO' não foi encontrado" And when you run it you get the following error me...
asked by 16.05.2017 / 05:40
2
answers

How to get the current path of a .sh script?

On Linux-based systems whenever I need to use the following command: #!/bin/bash BASEDIR=$(dirname "$0") echo $BASEDIR I have however read in different places that $(dirname "$0") is not supported by Mac OS X systems and BSD-based...
asked by 01.08.2016 / 17:51