Feb 28
|
HW01:
-
(1p) Write a command that prints the second oldest file in a directory
-
(1p) Create a file containing numbers from 1 to 100, one number on each line (use the 'seq' command), print only lines containing numbers from 24 to 42
-
(1p) Count the number of hidden files/directories in the current directory (try your home directory) excluding "." and ".."
|
Mar 07
|
HW02:
-
(1p) Write a command which sets a last modification time of a file to 9th November 2001, 11:55. If the file does not exist, do not create the file!
-
(1p) Write a command that lists all directories (in the current directory) that have name containing a number but not starting with a number.
-
(1p) Let's say that the solutions for this batch of homeworks are stored in files hw2-1.sh, hw2-2.sh. Write command, that sends me these solutions via email (Concatenated in the body of the email). (Note: Submit all your solutions the usual way via SIS, don't send me the email.)
|
Mar 14
|
HW03:
-
(1p) Set your default file creation mode mask so that each file you create has automatically read/write permission for owner, is readable by its group, and is inaccessible by other users.
-
(1p) Write a command that removes a read permission from other users for a directory and for its directory subtree (files and directories).
-
(1p) Set a read/write/execute permissions for owner read/execute for group and read-only for other to a file, via octal numeric way (0,5p) and via symbolic way (0,5p).
|
Mar 21
|
HW04:
-
(1p) Count the number of different login-shells that are listed in "/etc/passwd".
-
(1p) Replace the GID values in "/etc/group" by the "-". Leave the rest unchanged.
-
(1p) You have a file corpus-small.txt containing English sentences and their translations, each on separate line, each sentence pair separated by an empty line.
Transform the file, so that on each line, it contains both the English sentence and its translation, separated by a tabulator (default paste field separator)
The resulting file should look like this.
|
Mar 28
|
HW05:
-
(1p) Using the files countrycodes_en.csv and kodyzemi_cz.csv, print the countries that have identical names in Czech and in English.
-
(1p) Write a command that prints all files in the root directory tree that are executable by all users and are not owned by root.
-
(1p) Sort the /etc/group file by the number of users in the group (list in the file) decreasingly. When the number of users is equal, sort the sublist by the group name.
(Hint: If you replace each user by a special symbol, you can use the lenght of the resulting string to sort them alphabetically.)
|
Apr 04
|
HW06:
-
(1p) Write a command which finds every file ending with ".txt" in the directory subtree and for each file creates a copy ending with ".txt.bak" located in the same directory as the original file.
-
(1p) For every file in /usr/include with filename ending in ".h", print its file name and all lines in the file that start with "#include" (Use grep to gather the lines.).
-
(1p) Write a command that deletes all softlinks from the /tmp directory subtree that do not point to an existing file. (hint: you can use "cat" on the file to detect whether it exists.)
|
Apr 11
|
HW07:
-
(1p) Output a list of files from /usr/bin that are shell scripts (hint: use "file" command to get the file type; output of "file" is "filename: description"; shell scripts are described as "POSIX shell script").
-
(1p) Create a script that takes an input text and separates each symbol by a whitespace (preserve the original whitespaces by a special character) (0,5p). Then create a script that reconstructs the original text (0,5p).
-
(1p) Put a "#" symbol in front of every line from /etc/passwd, where UID=GID. (hint: grepping such lines can help you create the necessary regex).
|
Apr 18
|
HW08:
-
(1p) Write a script in sed that modifies an input stream (containing only alphanumeric characters) by reversing the sequence of characters on each line (e.g. "abcdef" to "fedcba") .(Hint: use conditioned branching to modify whole line multiple times.)
-
(1p) Write a shell script that takes n+1 parameters, first parameter is expr operator (escaped) the rest is sequence of numbers on which the operator is subsequentially applied (e.g. "./script.sh '+' 1 2 3" prints 6).
-
(1p) Write a shell script that prints its parameters each on a separate line sorted alphabetically (ascending).
|
Apr 25
|
HW09:
(Make sure that your solutions also check the parameters (whether they are correct, whether there is correct number of parameters etc.). Solutions that do not check the parameters correctly will receive only half of the points.)
-
(1p) Write a script which works as cp but with reversed order of parameters (the target is the first parameter).
-
(2p) Write a script which expects three parameters (in this order): file_name, number 'n' and a character 'c'. The script then performs a circular right shift of 'n' fileds, the fields are separated by the 'c' (input is in the file specified by the first parameter). Output is written to STDOUT. Example
|
May 2
|
HW10:
-
(1p) Write the script similar to the task 3) from the lab10 but for each target, that is older than some of its dependencies, print also, which dependencies are newer than the target in a format similar to input (target : z1 z2 .. zN)
-
(2p) Write a script that takes two number parameters: month and year, passes them to the "cal" command and prints the output according to the following example.
|
May 9
|
HW11:
-
(1p) Assume that the input lines contain only characters '(' and ')', write a sed script which checks whether each input line contains string of well paired brackets. The correct lines are replaced with 'ok' string, the wrong lines with 'wrong' string. (e.g. string '(())()((()))' would be 'ok', while string '(((())()' would be 'wrong').
-
(2p) Write a sed script that takes an input containing paragraphs that are separated by an empty line (each paragraph can be on multiple lines) and outputs each paragraph to a single line (the empty lines are removed in the process).
|
May 23
|
HW12:
-
(3p) Write an awk script which expects a file in the csv format at the input. This means that each line of the input line consists of several fields separated with a comma ",". The first line is the header line, it contains the column names. The first column of the subsequent lines contains a name, the rest of columns contain numbers. The script adds a new column called “Sum” (in the header line), which on each line contains the sum of the number fields.
|