The contest assignments

The contest consists of 10 tasks, each of which costs 10 points when the assignment is completed correctly and meets all the requirements.

The maximum score for all the assignments is 100.

The task 1

Create a file of the following specific format:

YYYY-DD-MM
hh:mm
1
12
123
1234
12345
123456
….
123456789101112131415
….

where YYYY-MM-DD is current date and hh:mm – current time

Then there are lines with numbers from 1 to N, where N is passed as an argument

Input format

ARG1 – path to the output file
ARG2 – N

Output format

The format was described above.

Example of usage

./script.sh /tmp/results.txt 15

The task 2

A directory containing a certain number of files with different extensions is given. Create a file with contents of the following format:

 Path_to_dir    filename_without_extension    extension./tmp/mydir file  txt
./tmp/mydir file  csv
./tmp/mydir file24  jpeg
./tmp/mydir myvideo  avi
./tmp/mydir/dir2 file txt
./tmp/mydir/dir2 photo15 jpeg

Input format

ARG1 – path to the input directory
ARG2 – path to the output file

Output format

Each file is presented as a separate line of a certain format
Path_to_directory    filename_without_extension     extension

Example of usage

/script.sh /tmp/mydir /tmp/results.txt

The task 3

A template file is provided. Create a file from the template, replacing all service combinations with the actual data. {{1}} must be replaced with an argument passed immediately after the name of the resulting file. {{2}} must be replaced with the next parameter and so on. In total, the script should process a maximum of {{9}}

Input format

ARG1 – path to the template
ARG2 – path to the output file
ARG3 – the argument to which all occurrences of the symbol group {{1}} should be replaced by the symbols provided in the ARG4 {{2}}
ARG4 -a group of symbols for replacing by

A maximum of up to {{9}} parameters can be passed to the script

Output format

The result of the work must be saved in a separate file

Example of usage

./script.sh /tmp/source.txt /tmp/results.txt Chris US Cupertino, где
{{1}} = Chris
{{2}} = US
{{3}} = Cupertino

The task 4

Calculate the integral (x * x * x-2x + 1) dx in the section from A to B with step H by the trapezium method with an accuracy of 10 ^ (-5). The result is displayed on the screen.

Input format

ARG1 – start of the segment (A)
ARG2 – end of the segment (B)
ARG3 – step (H)

Output format

Calculated value of the integral.
Example of output:  0.552323

Example of usage

./script.sh -5 5 0.1

The task 5

Print a file with numerical sequence of prime numbers.

Input format

ARG1 -a number of natural numbers starting from one

ARG2 – path to the output file

Output format

Each line contains one number in ascending order

Example of usage

./script.sh 5 /tmp/results.txt

The task 6

Analyze the text contained in the file with the original data. Display the file on the screen, highlighting all words containing a specific letter.

SymbolsBacklight color
A a O oRed
Y y W wGreen
H h D dYellow
U uBlue

Input format

ARG1 – path to the input file

Output format

Text on the screen where individual words are highlighted in a specific color

Example of usage

./script.sh /tmp/source.txt

The task 7

A directory containing specific files and directories is given. It is required to find and delete files that match all the criteria at once:

  • Owned by user USER
  • File larger than SIZE bytes
  • Text file (extension .txt)
  • File containing at least one mention of the months of the year (January, February, etc)

Input format

ARG1 – the input directory
ARG2 – name of the user
ARG3 – size of the file

Output format

All files from the input directory that match all criteria are listed.

Example of usage

./script.sh /tmp/mydir user15 10240

The task 8

A directory with a certain set of files in the format NNN.jpg, where N is a digit from 0 to 9 is provided. It is required to rename the files in the format “photo-MMM.jpg”, where MMM is the sequential number of the photo. The ordinal names of MMM are running in a row without “empty spaces”. If the number is less than 100, then you need to add leading zeros.

Input format

ARG1 – the subdirectory with data

Output format

Given the files 015.jpg, 055.jpg, 998.jpg and 998.jpg as an example, the script should rename them as shown below:

015.jpg – > 001.jpg
055.jpg – > 002.jpg
998.jpg – > 003.jpg
999.jpg – > 004.jpg

Example of usage

./script.sh /tmp/source.dir

The task 9

Find in a given text file all references to the correct date (including analysis for correctness on February 29 and so on) in YYYY-MM-DD format. Output the results in a separate file.

Input format

ARG1 – name of the input file
ARG2 – name of the output file

Output format

Each found sample of the correct date must be saved as a new line in the resulting file

Example of usage

./script.sh /tmp/source.txt /tmp/results.txt

The task 10

Decrypt an encrypted file. Save the result to a separate file. The encryption algorithm is described below.

All characters are left unchanged, except for the ones listed below.

A letterReplaced by
AB
BA
ac
ca

Input format

ARG1 – path to the encrypted file (input)
ARG2 – path to the decrypted file (output)

Output format

Text file with reverse character substitution.

Example of usage

./script.sh /tmp/source.txt  /tmp/results.txt