In the past I’ve did a post about checking if a bash argument is set. This is different, This way you can pass through a named variable.
TEST='pass it on' ./testscript.sh
If you do this $TEST will be set inside the ./testscript.sh bash script. Like the normal arguments you probably would like to validate them inside the bash script. The main plus side is that you can put arguments in any order and exclude arguments. It might also be easier to read as you can see the arguments name.
A bit more advanced. You can override global variables for that script run. Variables like $PWD and $PATH, be careful.
Example script: ./testscript.sh
if [ ! -z $TEST ]; then
echo "var is set to '$TEST'";
echo "var is unset";
Sometimes you just want to copy files from a remote server, and you want it often and quick. Stuff like a DB dump. You could startup your (s)ftp client and browse to it. Or you could just grab it with ssh.
There is a downside, it won’t update. Unless you up the version inside the repositories block. The upside is that this is lightweight, especially if the rest of the repo is big. This is rarely the right solution.
I like doing a lot in one command. Downside it that stuff can get messy. One big line. you can’t easily edit it. A shortcut to make it easier is ctrl-x-e That will open the current command in an editor.
Few thinks to keep in mind.
Multiple lines will work, but it will execute it as separate commands.
using && at the end of lines will fix that.
Which of course means you get it in the bash history at full. This is my main use to chain commands.
The site had 20K plus posts/pages/ect, freshly put live.
The hoster called. It had slow queries, 9 seconds on average. A lot, multiple per minute. The same query over and over again. It was a pretty normal post table query. It had one part extra. A meta query was to exclude all spot_closed posts. When I removed that it was quick. It didn’t show anything special.