From ae0847fbcd0c547a38c6d03f8a510365a3348d59 Mon Sep 17 00:00:00 2001 From: miguel Date: Wed, 30 Nov 2022 17:26:27 +0000 Subject: [PATCH] feat(change-struct): add subject, test and solution for new a exercise --- sh/tests/change-struct_test.sh | 16 ++++ .../solutions/new-struct/0_to_3/3/text.txt | 0 sh/tests/solutions/new-struct/4/text2.txt | 0 sh/tests/solutions/new-struct/A/text3.txt | 0 sh/tests/solutions/new-struct/done.tar | Bin 0 -> 10240 bytes subjects/change-struct/README.md | 79 ++++++++++++++++++ 6 files changed, 95 insertions(+) create mode 100755 sh/tests/change-struct_test.sh create mode 100644 sh/tests/solutions/new-struct/0_to_3/3/text.txt create mode 100644 sh/tests/solutions/new-struct/4/text2.txt create mode 100644 sh/tests/solutions/new-struct/A/text3.txt create mode 100644 sh/tests/solutions/new-struct/done.tar create mode 100644 subjects/change-struct/README.md diff --git a/sh/tests/change-struct_test.sh b/sh/tests/change-struct_test.sh new file mode 100755 index 00000000..65942ee6 --- /dev/null +++ b/sh/tests/change-struct_test.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Unofficial Bash Strict Mode +set -euo pipefail +IFS=' +' + +print_content() { + mkdir -p uncompressed + tar -xpf done.tar -C uncompressed + tree uncompressed +} + +submitted=$(cd student/new-struct && print_content) +expected=$(cd solutions/new-struct && print_content) +diff <(echo "$submitted") <(echo "$expected") diff --git a/sh/tests/solutions/new-struct/0_to_3/3/text.txt b/sh/tests/solutions/new-struct/0_to_3/3/text.txt new file mode 100644 index 00000000..e69de29b diff --git a/sh/tests/solutions/new-struct/4/text2.txt b/sh/tests/solutions/new-struct/4/text2.txt new file mode 100644 index 00000000..e69de29b diff --git a/sh/tests/solutions/new-struct/A/text3.txt b/sh/tests/solutions/new-struct/A/text3.txt new file mode 100644 index 00000000..e69de29b diff --git a/sh/tests/solutions/new-struct/done.tar b/sh/tests/solutions/new-struct/done.tar new file mode 100644 index 0000000000000000000000000000000000000000..1f5cb9f3df314d413a14b2fa636ffcef97bb9c74 GIT binary patch literal 10240 zcmeI1-AV&75QXz7`vi7o^QV`6lHx@XK@l{CKE4^7m9klol#E0?xe1+YC(C>}$z+xe z>Fr>5Mzc|FF?y3bj-IZ28Ioq$S;ryf$MSQ`o}HPz=1VQUPao;=eVWYc^V8}0vRLc> zr}6q9f5Ji+{;DfL05|dvK7jvkETC`x>3B|e>6{cM75*W(YuzvVfDB1n>EGJOW+H`m zsa!(;vj3Cj2_S%*^>3m7YON|5ivD>x{y6^?XxA?h5xi6MUJk zUH=p~*MIT-X9HMg)BfxJXGgpLIm-DT>i?Z#!yO`k2p|H803v`0AOeWMzmLEta`r6; literal 0 HcmV?d00001 diff --git a/subjects/change-struct/README.md b/subjects/change-struct/README.md new file mode 100644 index 00000000..882e76be --- /dev/null +++ b/subjects/change-struct/README.md @@ -0,0 +1,79 @@ +## Change struct + +You need to rearrange the file structure that you created earlier in the "file-struct" exercise. +Here is an example of how to move, rename, copy and delete a file or repo: + +**_Copy_** + +```console +cp `file to copy` `path of destination` +cp -r `repo to copy` `path of destination` +``` + +**_Move or Rename_** + +```console +User-> mv `file to move` `path of destination` +User-> mv -r `repo to move` `path of destination` +User-> ls +text.txt old_repo +User-> mv text.txt new_text.txt +User-> mv old_repo new_repo +User-> ls +new_text.txt old_repo +``` + +**_Delete_** + +```console +User-> rm `file to remove` +User-> rm -r `repo to remove` +``` + +### Instructions + +Use those commands to create the following file structure: + + - Copy the `struct` repo that you created and change its name to `new_struct`. + - Create the `0_to_3` and `6_to_9` folders. + - Move the folder `0, 1, 2 and 3` inside the `0_to_3` folder. + - Move the folder `6, 7, 8 and 9` inside the `6_to_9` folder. + - Remove the folder `5`. + - Rename the folder `10`, to `new_folder` + - Copy the folder `1` inside the folder `8` + +In this exercise you wil use the command `tree` to see the file structure as in the example bellow. `tree` is a recursive directory listing program that produces a depth-indented listing of files. With no arguments, `tree` lists the files in the current directory. + +```console +User-> tree new-struct/ +new-struct/ +├── 0_to_3 +│   ├── 0 +│   ├── 1 +│   ├── 2 +│   └── 3 +│   └── text.txt +├── 4 +│   └── text2.txt +├── 6_to_9 +│   ├── 6 +│   ├── 7 +│   ├── 8 +│   └── 9 +└── A + └── text3.txt +``` + +Once it is done, use the command below to create the file `done.tar` to be submitted. + +```console +User-> tar -cf done.tar * +User-> ls new-struct/ +0_to_3 4 6_to_9 A done.tar +``` + +**Only `done.tar` should be submitted.** + +**Tips:** + +Use the command `man ` to get more info on some command that you need to use.