| Both sides previous revision Previous revision | |||
|
os_cp:exercises-shell [2025/03/31 16:16] jkonczak |
os_cp:exercises-shell [2026/04/16 01:24] (current) jkonczak |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | In the exercises, one may also provide names of intractive programs (e.g., ''htop'' for process management, but if one chooses so, then one has to specify what needs to be done after starting the program in order to solve the exercise. | + | In the exercises, one may also provide names of interactive programs (e.g., ''htop'' for process management, but if one chooses so, then one has to specify what needs to be done after starting the program in order to solve the exercise. |
| \\ | \\ | ||
| - | For instance, if the exercise states //Provide a command, that will let an already running process called ''expensiveComputations'' use only the zeroth CPU core//, then the correct asnwers are, among others:\\ | + | For instance, if the exercise states //Provide a command, that will let an already running process called ''expensiveComputations'' use only the zeroth CPU core//, then the correct answers are, among others:\\ |
| //''taskset -c 0 -p $(pgrep expensiveComputations)''//,\\ | //''taskset -c 0 -p $(pgrep expensiveComputations)''//,\\ | ||
| or //start ''htop'', look up ''expensiveComputations'' with the shortcut ''/'', press 'a' to change affinity//, \\ | or //start ''htop'', look up ''expensiveComputations'' with the shortcut ''/'', press 'a' to change affinity//, \\ | ||
| Line 20: | Line 20: | ||
| ~~#.#~~. Look up in the system manual for the ''yt-dlp'' program an option that extracts only audio from the given link, and provide a command that will download only audio from %%https://www.youtube.com/watch?v=de2Hsvxaf8M%%. | ~~#.#~~. Look up in the system manual for the ''yt-dlp'' program an option that extracts only audio from the given link, and provide a command that will download only audio from %%https://www.youtube.com/watch?v=de2Hsvxaf8M%%. | ||
| - | ~~#.#~~. Provide a command, that will log you SSH sever available at the ''alt.org'' address as the user ''nethack''. | + | ~~#.#~~. Provide a command that will log you SSH sever available at the ''alt.org'' address as the user ''nethack''. |
| - | ~~#.#~~. Provide a command, that logs you via SSH on the computer named ''slurm'' as your current user, without providing the username within the command((You can verify if your command works issuing it from the polluks server)). | + | ~~#.#~~. Provide a command that logs you via SSH on the computer named ''slurm'' as your current user, without providing the username within the command((You can verify if your command works issuing it from the polluks server)). |
| - | ~~#.#~~. Provide a command, that outputs the current working directory. | + | ~~#.#~~. Provide a command that outputs the current working directory. |
| - | ~~#.#~~. Provide a command, that enters the directory ''db'' located in the directory ''var'' that is directly in the root directory. | + | ~~#.#~~. Provide a command that enters the directory ''db'' located in the directory ''var'' that is directly in the root directory. |
| - | ~~#.#~~. Provide a command, that changes the directory to the ''Documents'' directory that is one directory up from your working directory. | + | ~~#.#~~. Provide a command that changes the directory to the ''Documents'' directory that is one directory up from your working directory. |
| - | ~~#.#~~. Provide a single command, that displays the contents of ''.config'' and ''.local'' directories that both are in yout home directory. | + | ~~#.#~~. Provide a single command that displays the contents of ''.config'' and ''.local'' directories that both are in your home directory. |
| - | ~~#.#~~. Provide a command, that displays all files (including the hidden files) in the ''/tmp'' directory. | + | ~~#.#~~. Provide a command that displays all files (including the hidden files) in the ''/tmp'' directory. |
| - | ~~#.#~~. Provide a command, that lists files in the ''/usr/lib64/python/'' directory so that the size of files are shown. | + | ~~#.#~~. Provide a command that lists files in the ''/usr/lib64/python/'' directory so that the size of files are shown. |
| - | ~~#.#~~. Tell what is the size in MB of the file ''/usr/bin/gdb'' and provide the command you used to tell that. | + | ~~#.#~~. Tell what is the size, in MB, of the file ''/usr/bin/gdb'' and provide the command you used to tell that. |
| - | ~~#.#~~. Provide a command, that displays the contents of the ''elementary school'' directory which is a subdirectory of the ''old photos'' directory (both directories have a space in the name). | + | ~~#.#~~. Provide a command that displays the contents of the ''elementary school'' directory which is a subdirectory of the ''old photos'' directory (both directories have a space in the name). |
| ~~#.#~~. Provide a name of the most recently modified file in the ''/var/log'' directory and provide the command you used to learn that. | ~~#.#~~. Provide a name of the most recently modified file in the ''/var/log'' directory and provide the command you used to learn that. | ||
| Line 52: | Line 52: | ||
| ~~#.#~~. Provide a single command that creates a directory ''2024'' in a directory ''data'', creating thereby the ''data'' directory if it's missing. | ~~#.#~~. Provide a single command that creates a directory ''2024'' in a directory ''data'', creating thereby the ''data'' directory if it's missing. | ||
| - | ~~#.#~~. Provide a single command that creates directories ''moje obrazy'' and ''moja muzyka''. | + | ~~#.#~~. Provide a single command that creates directories ''my images'' and ''my music'' (heed the spaces). |
| - | ~~#.#~~. Provide a command, that remove an empty directory ''Downloads''. | + | ~~#.#~~. Provide a command that removes an empty directory ''Downloads''. |
| - | ~~#.#~~. Provide a command, that creates a (hard) link named ''commandHistory'' to the file ''.bash_history''. | + | ~~#.#~~. Provide a command that creates a (hard) link named ''commandHistory'' to the file ''.bash_history''. |
| ~~#.#~~. Provide a single command that creates a (hard) link to files ''~/.config/mimeapps.list'' and ''.config/htop/htoprc'' in your home directory. | ~~#.#~~. Provide a single command that creates a (hard) link to files ''~/.config/mimeapps.list'' and ''.config/htop/htoprc'' in your home directory. | ||
| - | ~~#.#~~. Provide a command, that creates a symbolic link to the file ''/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq'' named ''cpu0_frequency'' in the current directory. | + | ~~#.#~~. Provide a command that creates a symbolic link to the file ''/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq'' named ''cpu0_frequency'' in the current directory. |
| - | ~~#.#~~. Provide a command, that creates a symbolic link named ''up'' that points to the parent directory of the current directory. | + | ~~#.#~~. Provide a command that creates a symbolic link named ''up'' that points to the parent directory of the current directory. |
| - | ~~#.#~~. Provide a command, that copies all files with the ''.jpg'' extension form the directory ''pictures'' to the directory ''/tmp/a''. | + | ~~#.#~~. Provide a command that copies all files with the ''.jpg'' extension from the directory ''pictures'' to the directory ''/tmp/a''. |
| - | ~~#.#~~. Provide a command, that copies the directory ''.local'' from your home directory alongside with its contents to the desktop((which is usually the directory ''Desktop'' in your home directory)) with the name ''the local files''. | + | ~~#.#~~. Provide a command that copies the directory ''.local'' from your home directory alongside with its contents to the desktop((which is usually the directory ''Desktop'' in your home directory)) with the name ''the local files''. |
| - | ~~#.#~~. Podaj komendę (wykonywaną z katalogu domowego), którą stworzysz kopię pliku ''.bashrc'' pod nazwą ''.bashrc.bak'' tak, by kopia miała tę samą datę modyfikacji co oryginał. | + | ~~#.#~~. Provide a command (to be issued from your home directory) that creates a copy of the ''.bashrc'' file under the name ''.bashrc.bak'' in such a way, that the copy has identical modification date as the original file. |
| - | ~~#.#~~. Provide a command, that moves all files with the ''*.txt'' extension from your home directory to a ''notes'' directory. | + | ~~#.#~~. Provide a command that moves all files with the ''*.txt'' extension from your home directory to a ''notes'' directory. |
| - | ~~#.#~~. Provide a command, that amends the name of the file ''haunted hose.png'' to ''haunted house.png''. | + | ~~#.#~~. Provide a command that amends the name of the file ''haunted hose.png'' to ''haunted house.png''. |
| - | ~~#.#~~. Provide a command, that amends the name of the ''soembdoy'' directory that is located in the ''/tmp'' directory to ''somebody''. | + | ~~#.#~~. Provide a command that amends the name of the ''soembdoy'' directory that is located in the ''/tmp'' directory to ''somebody''. |
| - | ~~#.#~~. Provide a command, that removes the ''temporary file'' file from the ''/tmp'' directory. | + | ~~#.#~~. Provide a command that removes the ''temporary file'' file from the ''/tmp'' directory. |
| - | ~~#.#~~. Provide a command, that removes all contents from the ''.cache'' directory located in your home directory (without removing the directory itself). | + | ~~#.#~~. Provide a command that removes all contents from the ''.cache'' directory located in your home directory (without removing the directory itself). |
| - | ~~#.#~~. Provide a command, that removes write-protected file ''readOnly'' without asking for confirmation. | + | ~~#.#~~. Provide a command that removes write-protected file ''readOnly'' without asking for confirmation. |
| - | ~~#.#~~. Provide a command, that removes all files with the extensions ''.toc'', ''.nav'' and ''.aux'' in the current directory. | + | ~~#.#~~. Provide a command that removes all files with the extensions ''.toc'', ''.nav'' and ''.aux'' in the current directory. |
| - | ~~#.#~~. Provide a command, that removes all files which name starts with ''try'' and ends with ''.c'' from the directory ''programming''. | + | ~~#.#~~. Provide a command that removes all files which name starts with ''try'' and ends with ''.c'' from the directory ''programming''. |
| -------------------- | -------------------- | ||
| **~~#~~. Processes.** | **~~#~~. Processes.** | ||
| - | ~~#.#~~. Provide a command, that runs the ''lsof'' program and measures its run time. | + | ~~#.#~~. Provide a command that runs the ''lsof'' program and measures its run time. |
| ~~#.#~~. Provide the process identifier of your current shell and provide the command you used to learn that. | ~~#.#~~. Provide the process identifier of your current shell and provide the command you used to learn that. | ||
| Line 101: | Line 101: | ||
| ~~#.#~~. Provide the name of the program that uses most space in the main memory with its non-shared files (that is, consider //__res__ident set size// only). Provide the command you used to learn that. | ~~#.#~~. Provide the name of the program that uses most space in the main memory with its non-shared files (that is, consider //__res__ident set size// only). Provide the command you used to learn that. | ||
| - | ~~#.#~~. Run in another terminal the command ''sleep 1h'', and in yet another ''sleep 2h''. Provide a command, that will tell the process identifier of the process sleeping for an hour. | + | ~~#.#~~. Run in another terminal the command ''sleep 1h'', and in yet another ''sleep 2h''. Provide a command that will tell the process identifier of the process sleeping for an hour. |
| - | ~~#.#~~. Run in another terminal the command ''sleep 1h''. Provide a command, that will terminate the process from another terminal. | + | ~~#.#~~. Run in another terminal the command ''sleep 1h''. Provide a command that will terminate the process from another terminal. |
| - | ~~#.#~~. Run in another terminal the command ''mkpasswd''. Provide a command, that will send a ''FPE'' signal to the process. | + | ~~#.#~~. Run in another terminal the command ''mkpasswd''. Provide a command that will send a ''FPE'' signal to the process. |
| - | ~~#.#~~. Run in another terminal the command ''mkpasswd''. Provide commands, that will send a ''HUP'' signal to the shell in which the ''mkpasswd'' process is running. | + | ~~#.#~~. Run in another terminal the command ''mkpasswd''. Provide commands that will send a ''HUP'' signal to the shell in which the ''mkpasswd'' process is running. |
| -------------------- | -------------------- | ||
| **~~#~~. Users. File Permissions.** | **~~#~~. Users. File Permissions.** | ||
| - | ~~#.#~~. Provide a command, that displays your username. | + | ~~#.#~~. Provide a command that displays your username. |
| - | ~~#.#~~. Provide a command, that displays to which groups the current user belongs. | + | ~~#.#~~. Provide a command that displays to which groups the current user belongs. |
| - | ~~#.#~~. Provide a command, that displays to which groups the ''root'' user belongs. | + | ~~#.#~~. Provide a command that displays to which groups the ''root'' user belongs. |
| ~~#.#~~. Provide to which user and which group the file ''/dev/console'' belongs and provide the command you used to learn that. | ~~#.#~~. Provide to which user and which group the file ''/dev/console'' belongs and provide the command you used to learn that. | ||
| Line 130: | Line 130: | ||
| ~~#.#~~. Tell which users can see the contents of the file ''.bash_history'' in your home directory. | ~~#.#~~. Tell which users can see the contents of the file ''.bash_history'' in your home directory. | ||
| - | ~~#.#~~. Provide a command, that revokes the users that do not belong to your group permission to read the file ''our secret data.txt''. | + | ~~#.#~~. Provide a command that revokes the users that do not belong to your group permission to read the file ''our secret data.txt''. |
| - | ~~#.#~~. Provide a command, that forbids access (read, write and execute) to your file ''~/public_html/index.php'' (belonging to the group ''students'') to other students, but does not forbid access to the http server (that does not belong to the grup ''students'')((Files that are put in the ''public_html'' subdirectory of the home directory of the user //username// are accessible at the URL %%https://sirius.cs.put.poznan.pl/~%%//username//%%/%%.)). | + | ~~#.#~~. Provide a command that forbids access (read, write and execute) to your file ''~/public_html/index.php'' (belonging to the group ''students'') to other students, but does not forbid access to the http server (that does not belong to the group ''students'')((Files that are put in the ''public_html'' subdirectory of the home directory of the user //username// are accessible at the URL %%https://sirius.cs.put.poznan.pl/~%%//username//%%/%%.)). |
| ~~#.#~~. Provide a single command that sets the permissions to the file ''access_log'' so that the group can only write to the file, you can only read it, and the remaining users have no access to the file. | ~~#.#~~. Provide a single command that sets the permissions to the file ''access_log'' so that the group can only write to the file, you can only read it, and the remaining users have no access to the file. | ||
| - | ~~#.#~~. Provide a command, that changes the permissions to the ''/tmp/myDir'' directory so that the users apart from you can display the file ''/tmp/myDir/pub.txt'', but cannot list the files in the ''/tmp/myDir'' directory. | + | ~~#.#~~. Provide a command that changes the permissions to the ''/tmp/myDir'' directory so that the users apart from you can display the file ''/tmp/myDir/pub.txt'', but cannot list the files in the ''/tmp/myDir'' directory. |
| - | ~~#.#~~. Provide a command, that lets the user ''jkonczak'' belonging to the groups ''staff'' and ''lindev'' read and execute the ''exercise.sh'' file in your home directory on polluks, but forbids the user ''ai11111'' belonging to the group ''students'' reading the file. | + | ~~#.#~~. Provide a command that lets the user ''jkonczak'' belonging to the groups ''staff'' and ''lindev'' read and execute the ''exercise.sh'' file in your home directory on polluks, but forbids the user ''ai11111'' belonging to the group ''students'' reading the file. |
| ~~#.#~~. Tell when the contents of the file ''/etc/sudoers'' has been modified most recently. | ~~#.#~~. Tell when the contents of the file ''/etc/sudoers'' has been modified most recently. | ||
| Line 146: | Line 146: | ||
| ~~#.#~~. Tell when the file ''/var/log/wtmp'' has been created((the exercise is doable if the filesystem records file birth dates; it is the case on polluks)). | ~~#.#~~. Tell when the file ''/var/log/wtmp'' has been created((the exercise is doable if the filesystem records file birth dates; it is the case on polluks)). | ||
| - | ~~#.#~~. Provide a command, that changes the date od th last modification of the file ''treaty'' to ''1992-2-7 11:55'' | + | ~~#.#~~. Provide a command that changes the date of the last modification of the file ''treaty'' to ''1992-2-7 11:55'' |
| -------------------- | -------------------- | ||
| Line 152: | Line 152: | ||
| **~~#~~. Searching for files.** | **~~#~~. Searching for files.** | ||
| - | ~~#.#~~. Provide a command, that searches for all files that contain the word ''plasma'' in your home directory. | + | ~~#.#~~. Provide a command that searches for all files that contain the word ''plasma'' in your home directory. |
| - | ~~#.#~~. Provide a command, that searches for all directories which contain their name the string ''qt'', ignoring the letter case. | + | ~~#.#~~. Provide a command that searches for all directories which contain in their name the string ''qt'', ignoring the letter case. |
| - | ~~#.#~~. Provide a command, that searches for all ordinary files that end with ''.jpg'' or ''.jpeg'' in the directories ''Downloads'' and ''Dekstop'' in your home directory. | + | ~~#.#~~. Provide a command that searches for all ordinary files that end with ''.jpg'' or ''.jpeg'' in the directories ''Downloads'' and ''Dekstop'' in your home directory. |
| - | ~~#.#~~. Provide a command, that searches for all files with size greater than 1MB that were modified within last week. | + | ~~#.#~~. Provide a command that searches for all files with size greater than 1MB that were modified within last week. |
| -------------------- | -------------------- | ||
| Line 164: | Line 164: | ||
| **~~#~~. Redirections.** | **~~#~~. Redirections.** | ||
| - | ~~#.#~~. Provide a command, that executes and measures the run time of ''lsof'' command and puts the result of ''lsof'' in a file ''lsof.log'' | + | ~~#.#~~. Provide a command that executes and measures the run time of ''lsof'' command and puts the result of ''lsof'' in a file ''lsof.log'' |
| - | ~~#.#~~. Provide a command, that appends the current date to the file ''lsof.log''. | + | ~~#.#~~. Provide a command that appends the current date to the file ''lsof.log''. |
| - | ~~#.#~~. Provide a command, that displays the contents of the file ''/etc/protocols'' prepended with line numbers. | + | ~~#.#~~. Provide a command that displays the contents of the file ''/etc/protocols'' prepended with line numbers. |
| ~~#.#~~. Provide commands that, by means of redirections, create a file named ''1'' with numbers from 1 to 5 (each in separate line), and file ''5'' with numbers starting from 5, incremented by 5, up to 25 (each in separate line). | ~~#.#~~. Provide commands that, by means of redirections, create a file named ''1'' with numbers from 1 to 5 (each in separate line), and file ''5'' with numbers starting from 5, incremented by 5, up to 25 (each in separate line). | ||
| - | ~~#.#~~. Provide a command, that displays the contents of the files created in the previous exercise side by side. | + | ~~#.#~~. Provide a command that displays the contents of the files created in the previous exercise side by side. |
| - | ~~#.#~~. Provide a single command, that displays the contents of the files created in the previous exercise one after another. | + | ~~#.#~~. Provide a single command that displays the contents of the files created in the previous exercise one after another. |
| - | ~~#.#~~. Provide a command, that created a file ''message'' containing the text ''Premission denined'' using redirections. | + | ~~#.#~~. Provide a command that create a file ''message'' containing the text ''Permission denied'' using redirections. |
| - | ~~#.#~~. Provide a command, that executes the command ''find /var'' and discards the error messages. | + | ~~#.#~~. Provide a command that executes the command ''find /var'' and discards the error messages. |
| ~~#.#~~. Provide a command that will execute the command ''strace -e 'openat' ls ~'' so that the result of the ''ls'' command ends up in the ''ls.out'' file, and the (output to standard error) messages of the ''strace'' program end up in the ''ls.strace'' file. | ~~#.#~~. Provide a command that will execute the command ''strace -e 'openat' ls ~'' so that the result of the ''ls'' command ends up in the ''ls.out'' file, and the (output to standard error) messages of the ''strace'' program end up in the ''ls.strace'' file. | ||
| - | ~~#.#~~. Provide a command, that runs in the background the program ''glxgears'' and discards all its output. | + | ~~#.#~~. Provide a command that runs in the background the program ''glxgears'' and discards all its output. |
| - | ~~#.#~~. Provide a command, that runs ''wc'' replacing its stadard output with the file ''/etc/resolv.conf''. | + | ~~#.#~~. Provide a command that runs ''wc'' replacing its standard output with the file ''/etc/resolv.conf''. |
| - | ~~#.#~~. Provide a command, that tuns ''bc'' and passes to the standard input of that program the tow following lines: ''(4^4)^4'' and ''4^(4^4)''. | + | ~~#.#~~. Provide a command, that runs ''bc'' and passes to the standard input of that program the two following lines: ''(4^4)^4'' and ''4^(4^4)''. |
| -------------------- | -------------------- | ||
| Line 239: | Line 239: | ||
| </code></small> | </code></small> | ||
| - | ~~#.#~~. Provide a pipeline that, counts how many ''bash'' processes are currently running (for all users). | + | ~~#.#~~. Provide a pipeline that counts how many ''bash'' processes are currently running (for all users). |
| <small> \\ Example command output:<code> | <small> \\ Example command output:<code> | ||
| 8 | 8 | ||
| Line 284: | Line 284: | ||
| </code></small> | </code></small> | ||
| - | ~~#.#~~. Provide a command that finds out which header file in the directory ''/usr/include/'' contains the | + | ~~#.#~~. Provide a command that finds out which header file in the directory ''/usr/include/'' contains the declaration of the function ''SHA512_Init''. |
| - | declaration of the function ''SHA512_Init'' declaration . | + | |
| ~~#.#~~. Provide a pipeline that counts how many ''#'' characters are in the file found in the previous exercise. | ~~#.#~~. Provide a pipeline that counts how many ''#'' characters are in the file found in the previous exercise. | ||
| Line 341: | Line 340: | ||
| ~~#.#~~. Provide a pipeline that filters the output of 'ping -i 0.5 -c 10 put.poznan.pl', to display only the rtt times themselves. | ~~#.#~~. Provide a pipeline that filters the output of 'ping -i 0.5 -c 10 put.poznan.pl', to display only the rtt times themselves. | ||
| - | answers. | ||
| <small> \\ Sample command output:<code> | <small> \\ Sample command output:<code> | ||
| 1.20 | 1.20 | ||
| Line 362: | Line 360: | ||
| ~~#.#~~. Provide a command that redirects the combined output of the commands ''date'' and ''lsof'' to a file ''lsof.latest.log''. | ~~#.#~~. Provide a command that redirects the combined output of the commands ''date'' and ''lsof'' to a file ''lsof.latest.log''. | ||
| - | ~~#.#~~. Provide a fragment of the script that creates a directory ''results'' and exits id creating the directory failed. You must not use ''if'' statement or any loop. | + | ~~#.#~~. Provide a fragment of the script that creates a directory ''results'' and exits if creating the directory failed. You must use neither ''if'' statement nor a loop. |
| -------------------- | -------------------- | ||
| Line 372: | Line 370: | ||
| ~~#.#~~. Provide a keyboard shortcut that will normally stop (i.e. put to sleep) the foreground process. | ~~#.#~~. Provide a keyboard shortcut that will normally stop (i.e. put to sleep) the foreground process. | ||
| - | ~~#.#~~. Run the ''xterm'' program from the terminal. Stop the program with the appropriate shortcut. Provide a command that will resume the xterm process in background (i.e. so that you can continue to use both the current terminal and the xterm program). | + | ~~#.#~~. Run the ''xterm'' program from the terminal. Stop the program with the appropriate shortcut. Provide a command that will resume the ''xterm'' process in background (i.e. so that you can continue to use both the current terminal and the ''xterm'' program). |
| - | ~~#.#~~. Provide a command, that runs the command ''perl -e "system'fortune'while sleep 5"'' in background. | + | ~~#.#~~. Provide a command that runs the command ''perl -e "system'fortune'while sleep 5"'' in background. |
| - | ~~#.#~~. Provide a command, that moves the process running in background to foreground. | + | ~~#.#~~. Provide a command that moves the process running in background to foreground. |
| ~~#.#~~. Start ''mkpasswd'' in background first, and then start ''sleep 50'' in background. Provide a command that resumes the ''mkpasswd'' as a foreground process. | ~~#.#~~. Start ''mkpasswd'' in background first, and then start ''sleep 50'' in background. Provide a command that resumes the ''mkpasswd'' as a foreground process. | ||
| - | ~~#.#~~. Provide a command, that lists the processes running in background in the current shell. | + | ~~#.#~~. Provide a command that lists the processes running in background in the current shell. |
| -------------------- | -------------------- | ||
| Line 386: | Line 384: | ||
| **~~#~~. Environment variables.** | **~~#~~. Environment variables.** | ||
| - | ~~#.#~~. Provide a command, that sets the variable ''TEXT'' to the value ''That's "the" value'' (with all quotes intact). | + | ~~#.#~~. Provide a command that sets the variable ''TEXT'' to the value ''That's "the" value'' (with all quotes intact). |
| - | ~~#.#~~. Provide a command, that sets the variable ''FOO'' to the value ''baz'' so that programs run in this shell see the value of ''FOO''. (You can verify this by running the ''perl -e 'print "Correct!\n" if $ENV{"FOO"} == "baz"'%%%%'' command). | + | ~~#.#~~. Provide a command that sets the variable ''FOO'' to the value ''baz'' so that programs run in this shell see the value of ''FOO''. (You can verify this by running the ''perl -e 'print "Correct!\n" if $ENV{"FOO"} == "baz"'%%%%'' command). |
| ~~#.#~~. Provide a command that lists all currently set variables. | ~~#.#~~. Provide a command that lists all currently set variables. | ||
| Line 396: | Line 394: | ||
| ~~#.#~~. Provide a fragment of shell script that checks if the first argument names an existing file and the second argument names an existing directory, and if not, then prints an error message and quits the script. | ~~#.#~~. Provide a fragment of shell script that checks if the first argument names an existing file and the second argument names an existing directory, and if not, then prints an error message and quits the script. | ||
| - | ~~#.#~~. Provide a fragment of shell script that checks if the second argument is greater than the second argument, and if not, then prints an error message and quits the script. | + | ~~#.#~~. Provide a fragment of shell script that checks if the first argument is greater than the second argument, and if not, then prints an error message and quits the script. |
| ~~#.#~~. Provide a fragment of shell script that assigns to variable ''DEST'' the value of the second arguments if at least two arguments were provided, and ''./destination/'' otherwise. | ~~#.#~~. Provide a fragment of shell script that assigns to variable ''DEST'' the value of the second arguments if at least two arguments were provided, and ''./destination/'' otherwise. | ||
| - | ~~#.#~~. Provide a fragment of shell script that calls a program ''cat'' with argument ''-nv'' and full list of arguments of this script. <small>(That is, if the script was run as ''./script foo "baz bar"'', then the fragment shall call ''cat -nv foo "baz bar"''.)</small> | + | ~~#.#~~. Provide a fragment of shell script that calls a program ''cat'' with argument ''-nv'' and the full list of arguments of this script. <small>(That is, if the script was run as ''./script foo "baz bar"'', then the fragment shall call ''cat -nv foo "baz bar"''.)</small> |
| -------------------- | -------------------- | ||