|
|
|
|
|
| Description | Linux | Windows |
|
|
|
| :------------- | :---------- | :----------- |
|
|
|
| Hide commands from console | ? | `@echo off` |
|
|
|
| Access calling arguments | `$1`, `$2`, all args: `$@` | `%1`, `%2`, all args: `%*` |
|
|
|
| Print text | `echo "Some Text"` | `echo Some Text` |
|
|
|
| Print empty line | `echo ""` | `echo.` |
|
|
|
| Current Script Directory | `SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"` | `set SCRIPTS_DIR=%~dp0` |
|
|
|
| Test directory exists | `if [ ! -d "DIR" ]; then mkdir DIR; fi` | `if not exist %DIR% mkdir %DIR%` |
|
|
|
| Save current dir & cd | `pushd $DIR` | `pushd %DIR%` |
|
|
|
| Cd to last saved dir (pushd) | `popd` | `popd` |
|
|
|
| Call another script | `script.sh arguments` | `call script.bat arguments other_arg` |
|
|
|
| Import script as is | `. script.sh` | ? |
|
|
|
| Test if variable is set | `if [ -z "$VAR" ]; then CMD; fi` | `IF [%VAR%] == [] (CMD1; CMD2) else (CMD)` |
|
|
|
| Compare variable | `TODO` | `IF ["%VAR%"] == ["TEXT"]` |
|
|
|
| Copy file | `cp "path/file.ext" "target_dir"` | `copy "path\filename.ext" "target_dir\filename.ext"` |
|
|
|
| Move file (or rename) | `mv path/file other_path/[file]` | `move "path\filename.ext" "target_dir\filename.ext"` |
|
|
|
| Create dir | `mkdir name` | `mkdir name` |
|
|
|
| Remove dir (with contained files) | `rm -r $DIR` | `rmdir /S /Q %DIR` | |