From e06b02869784ada3d82328c0e6c4b3a001e47d53 Mon Sep 17 00:00:00 2001 From: miguel Date: Wed, 30 Nov 2022 17:03:44 +0000 Subject: [PATCH] feat(strange-files): add subject, test and solution for new a exercise --- .../solutions/\"\\?$*'First_file'*$?\\\"" | 1 + sh/tests/strange-files_test.sh | 8 ++++ subjects/strange-files/README.md | 43 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 "sh/tests/solutions/\"\\?$*'First_file'*$?\\\"" create mode 100755 sh/tests/strange-files_test.sh create mode 100644 subjects/strange-files/README.md diff --git "a/sh/tests/solutions/\"\\?$*'First_file'*$?\\\"" "b/sh/tests/solutions/\"\\?$*'First_file'*$?\\\"" new file mode 100644 index 000000000..f9406d9c8 --- /dev/null +++ "b/sh/tests/solutions/\"\\?$*'First_file'*$?\\\"" @@ -0,0 +1 @@ +Random text inside! \ No newline at end of file diff --git a/sh/tests/strange-files_test.sh b/sh/tests/strange-files_test.sh new file mode 100755 index 000000000..117af30e5 --- /dev/null +++ b/sh/tests/strange-files_test.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# Unofficial Bash Strict Mode +set -euo pipefail +IFS=' +' + +diff student/\"\\?\$*\'First_file\'*\$?\\\" solutions/\"\\?\$*\'First_file\'*\$?\\\" diff --git a/subjects/strange-files/README.md b/subjects/strange-files/README.md new file mode 100644 index 000000000..13f41c442 --- /dev/null +++ b/subjects/strange-files/README.md @@ -0,0 +1,43 @@ +## Strange Files + +We come across files and folders name very regularly. In most of the cases file/folder names are related to the content of the file/folder and starts with numbers or letters. Alpha-Numeric file name are pretty common and very widely used, but this is not the case when we have to deal with file/folder name that has special characters in them. + +Example of most common file names are: + +```console +something.txt +alphanum21.txt +674659.txt +``` + +Examples of file names that have special characters: + +```console +#121day.txt +some/file#.txt +*File$*.txt +``` + +When You create a file with some special character, you will need to `escape` those special characters in order to create that file. + +A non-quoted backslash `\` is the escape character. The backslash `\` preceding a character tells the shell to interpret that special character literally. + +Example: + +If you want to create a file named `foo!\.txt` You have to escape the characters like so: + +```console +User-> code foo\!\\.txt +``` + +### Instructions + +Create a file `"\?$*'First_file'*$?\"` that will contain `Random text inside!` and **nothing else**. + +### Usage + +```console +User-> ls | cat -e +"\?$*'First_file'*$?\"$ +User-> +```