This repository was archived by the owner on Jun 5, 2022. It is now read-only.
forked from DTixi/NJCU_Linux_Class
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMidtermExam.txt
More file actions
35 lines (27 loc) · 1.54 KB
/
Copy pathMidtermExam.txt
File metadata and controls
35 lines (27 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
##############################################################
################### MIDTERM EXAM ############################
##############################################################
Write the following programs on paper and turn in when complete.
Solutions should be simple, so there is no partial credit.
Code must run when typed into a bash script. You will have 15 minutes
to complete the exam.
Problem 1 [50 pts.]:
Write a bash oneliner to delete the 15 largest files under the current directory.
This will use pipes. Explain each step of the command.
You might use the 'find' and 'du' commands. We haven't talked about 'find' yet, and we haven't talked about 'du' - disk-usage since week 1.
You can probably google "how to delete the largest files in directory" or something like that to learn about how to do this. Make sure you
are deleting FILES and not DIRECTORIES!!!
hint to get you started:
https://unix.stackexchange.com/questions/22432/getting-size-with-du-of-files-only
Problem 2 [50 pts.]:
Write a bash script that outputs the following:
user@machine$ ./myScript filename.txt
e #####################... ( 26 #s )
f #####################... ( 25 #s )
a #####################... ( 24 #s )
.
.
. ( there should be 26 rows. The last row has a letter and a single # )
The program counts the letter frequencies in the input file and outputs 26 rows indicating which letter
is the most common all the way down to which letter is least common.
No python/ruby/java/etc. You have to use bash and common Linux command line tools.