subdir-test.sh
1 |
#!/bin/bash |
---|---|
2 |
|
3 |
echo "Enable extglob bash feature" |
4 |
shopt -s extglob |
5 |
shopt extglob |
6 |
|
7 |
# Prepare test-case |
8 |
cd /tmp/ |
9 |
mkdir -p subtest/client/cpp && cd subtest/client/cpp |
10 |
touch CMakeLists.txt && mkdir src && touch blubb.readme |
11 |
cd /tmp/subtest |
12 |
|
13 |
# Remove all but client |
14 |
rm -rf ./!(client) |
15 |
|
16 |
# Make temp dir |
17 |
temp=$(mktemp -d ./XXXXXXXX) |
18 |
|
19 |
# Copy contents of desired sub-folder to sub folder |
20 |
cp -R client/cpp/* ${temp}/ |
21 |
# Cleanup |
22 |
rm -rf client |
23 |
|
24 |
# Move desired content to top-level |
25 |
mv ${temp}/* . |
26 |
# Cleanup |
27 |
rm -rf ${temp} |
28 |
|
29 |
ls /tmp/subtest |
30 |
|
31 |
echo "Done." |