bash assign default value

Use a colon: The colon is a null command that does nothing and ignores its arguments. It is built into bash so a new process is not created.

Shell: How to call one shell script from another shell script?

There are a couple of different ways you can do this: Make the other script executable, add the #!/bin/bash line at the top, and the path where the file is to the $PATH environment variable. Then you can call it as a normal command; Or call it with the source command (alias is .), like this:source /path/to/script Or use the bash command to execute … Read more

BASH Syntax error near unexpected token ‘done’

Run cat -v file.sh. You most likely have a carriage return or no-break space in your file. cat -v will show them as ^M and M-BM- or M- respectively. It will similarly show any other strange characters you might have gotten into your file. Remove the Windows line breaks with

cp: missing destination file operand after

Variable assignments in bash scripts require no space between the variable name and value or (unless quoted) within the value. Since a space was present in the line FILEBACKUPLOCATION= /../…/FMonday, it attempted to execute /../…/FMonday as a command (which caused the first error) with FILEBACKUPLOCATION assigned to an empty string. The variable was then not assigned when the other command … Read more

Running Bash commands in Python

On my local machine, I run a python script which contains this line This works fine. Then I run the same code on a server and I get the following error message So what I did then is I inserted a print bashCommand which prints me than the command in the terminal before it runs it with os.system(). … Read more

Delete all local git branches

The ‘git branch -d’ subcommand can delete more than one branch. So, simplifying @sblom’s answer but adding a critical xargs: or, further simplified to: Importantly, as noted by @adminndrewC, using git branch for scripting is discouraged. To avoid it use something like: Caution warranted on deletes!

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)