# Bash

## Copy files from diff directory

{% tabs %}
{% tab title="==>" %}

```
#!/bin/bash

clear

PRJ_DIR="reports-ui"
REPORTS_SYNC_DIR="reports_sync"

ROOT="$(dirname $(dirname $(pwd)))"
SOURCE_DIR="$ROOT/$REPORTS_SYNC_DIR/$PRJ_DIR"
DESTINATION_DIR="$(dirname $(pwd))"
CURRENT_DIR="$(pwd)"

FILES=(
  "src/*;src/"
  "express-server/index.js;express-server/"
  "package.json;package.json"
  "prettier.config.js"
  ".env.development"
  ".env"
#  "public/locales"
#  "public/assets"
)

echo "Pulling changes from $SOURCE_DIR:"

cd $SOURCE_DIR
git pull

echo "--"

cd $CURRENT_DIR
for file in "${FILES[@]}"
do
  IFS=";" read -r -a item <<< "${file}"

  SOURCE="$SOURCE_DIR/${item[0]}"
  DEST="$DESTINATION_DIR/${item[1] | item[0]}"

  echo ""
  echo "copy $SOURCE to $DEST:"
#  cp -r $SOURCE $DEST
  rsync -a --exclude-from='excludelist.txt' $SOURCE $DEST
done

echo "Done"
```

{% endtab %}

{% tab title="Code" %}

```bash
```

{% endtab %}

{% tab title="excludelist.txt" %}

```
mocks/reports/
express-server/files/

```

{% endtab %}
{% endtabs %}
