Easily find issues by searching: #<Issue ID>
Example: #1832
Easily find members by searching in: <username>, <first name> and <last name>.
Example: Search smith, will return results smith and adamsmith
Write a script to carry out each of the following tasks.
Write a script that backs itself up, that is, copies itself to a file named backup.sh
.
Hint: Use the cat command and the appropriate positional parameter.
Perform a recursive directory listing on the user's home directory and save the information to a file. Compress the file, have the script prompt the user to insert a USB flash drive, then press ENTER. Finally, save the file to the flash drive after making certain the flash drive has properly mounted by parsing the output of df. Note that the flash drive must be unmounted before it is removed.
Convert the for loops in Example 11-1 to while loops. Hint: store the data in an array and step through the array elements.
Having already done the "heavy lifting," now convert the loops in the example to until loops.
Write a script that reads each line of a target file, then writes the line back to stdout
, but with an extra blank line following. This has the effect of double-spacing the file.
Include all necessary code to check whether the script gets the necessary command-line argument (a filename), and whether the specified file exists.
When the script runs correctly, modify it to triple-space the target file.
Finally, write a script to remove all blank lines from the target file, single-spacing it.
Write a script that echoes itself to stdout
, but backwards.
Given a list of filenames as input, this script queries each target file (parsing the output of the file command) for the type of compression used on it. Then the script automatically invokes the appropriate decompression command (gunzip
, bunzip2
, unzip
, uncompress
, or whatever). If a target file is not compressed, the script emits a warning message, but takes no other action on that particular file.
Generate a "unique" 6-digit hexadecimal identifier for your computer. Do not use the flawed hostid command. Hint: md5sum /etc/passwd, then select the first 6 digits of output.
Archive as a "tarball" (*.tar.gz
file) all the files in your home directory tree (/home/your-name
) that have been modified in the last 24 hours. Hint: use find.
Optional: you may use this as the basis of a backup script.
Given a process ID (PID) as an argument, this script will check, at user-specified intervals, whether the given process is still running. You may use the ps and sleep commands.
Print (to stdout
) all prime numbers between 60000 and 63000. The output should be nicely formatted in columns (hint: use printf).
One type of lottery involves picking five different numbers, in the range of 1 - 50. Write a script that generates five pseudorandom numbers in this range, with no duplicates. The script will give the option of echoing the numbers to stdout
or saving them to a file, along with the date and time the particular number set was generated. (If your script consistently generates winning lottery numbers, then you can retire on the proceeds and leave shell scripting to those of us who have to work for a living.)
About AquaClusters Privacy Policy Support Version - 19.0.2-4 AquaFold, Inc Copyright © 2007-2017