|
1. Write a command that will give a quick indication of the total number of bash shells running on hills. Use the ps, grep, and wc utilities.
2. Write a command that removes all files that end in a “.log” extension, and do not contain your first name. Remove them from your home directory, and all subdirectories, recursively.
3. Write a command that produces ‘ls –f’ output for the current directory. But only lists files and directories for which the ‘other’ category (as opposed to ‘user’ and ‘group’ categories) has execution permission.
4. Write a command that invokes the who utility, and then filters the output so that only users who originally logged on before February 20th are listed.
Scripts:
For the script writing section, just write the lines of the script as they would appear in a text file.
1. Write a two line script that finds all of the files that end in a “.txt” in you home directory (and all subdirectories, recursively) and combines their contents into a single file named “combined.txt”, and then removes all of “.txt” files.
2. Rewrite the script so that is accepts one argument. The argument should represent a file extension. The new script should combine and delete all files that end in that file extension. If the script was named myCombineScript, for example, and if was invoked as follows:
bash> myScript ‘.temp’
Then the script should combine and delete all files that end in ‘.temp’. It should name the combined file “combined.temp”. You can accomplish this by carefully placing $1 into your script from question 1 above.
Extra
For this section, just write the lines of the sed script as they would appear in a text file.
Write a sed script that will modify any input stream in the following ways:
1. All digits from 0 to 4 should be replaced with lower case x’s.
2. All digits from 5 to 9 should be replaced with upper case X’s.
3. Any line that begins with a ‘#’ character, and otherwise only contains capital letters and spaces, should be deleted.
4. Any line that contains your last name, and ends with an exclamation point (!) should be written to a file named “mentioned”. |
|