This is for my linux class. There\'s a lot of words but it\'s only one question.
ID: 3793517 • Letter: T
Question
This is for my linux class. There's a lot of words but it's only one question.
Performance Data
Curve Name
gge0001x
gge0001y
gge0001z
Date
12/30/2006
12/30/2006
12/30/2006
Time
14:15
14:15
14:16
Tamb (°C)
15.8
16.1
15.0
Tref (°C)
30.1
29.6
29.9
Tm (°C)
20.2
22.3
23.4
Irradiance (W/m^2)
1006.2
1003.5
999.8
Isc (A)
8.40
8.41
8.37
Voc (V)
37.14
36.82
36.62
Imp (A)
7.55
7.53
7.44
Vmp (V)
28.19
27.90
27.86
Pm (W)
212.86
210.15
207.15
FF (%)
68.3
67.9
67.6
Write a shell script called lab5.2 for the processing, which includes the steps below:
Step 1: Use grep/fgrep/egrep and sed to process individual files
The output of each file should be reduced to 19 rows and 2 fields separated by a single space character, as shown below:
F gge0001x
D 12-30-2006
T 14:15:20
S a69
B 15.8
M gge06001
P 30.1
Q 20.2
R 1006.2
U 1011.8
X 34.7
A 38.994
G 107.71
H 8.395
O 37.141
C 7.55
K 28.193
W 212.86
L 68.3
To do so:
Delete the unnecessary rows. Do not use line numbers, because your program can be tested on files where line numbers might not match
On each line, replace tab and multiple space characters with a single character
Extract the first field and save to a file called lineid
Extract the second field of each file and save as the curve name. For example, the second field of the first file should be saved into file gge0001x. A possible breakdown of this process is as follow:
Use the sed’s back reference feature to delete the first identification field
Since the second field is now the first field, use the back reference feature to delete everything after the first field.
Save the output file as gge0001[xyz].
Step 2: Use the paste command to obtain a file called lab5.2.2 similar to the one below:
F gge0001x gge0001y gge0001z
D 12-30-2006 12-30-2006 12-30-2006
T 14:15:20 14:15:55 14:16:27
S a69 a69 a69
B 15.8 16.1 15
M gge06001 gge06001 gge06001
P 30.1 29.6 29.9
Q 20.2 22.3 23.4
R 1006.2 1003.5 999.8
U 1011.8 1011.8 1005
X 34.7 35.2 35.1
A 38.994 38.994 38.994
G 107.71 107.71 107.71
H 8.395 8.406 8.368
O 37.141 36.823 36.621
C 7.55 7.532 7.437
K 28.193 27.902 27.856
W 212.86 210.15 207.15
L 68.3 67.9 67.6
Step 3: Use the awk command and filtering features to create the final format of the file, as shown in “Performance Data” table. Call this file lab5.2.3
Performance Data
Curve Name
gge0001x
gge0001y
gge0001z
Date
12/30/2006
12/30/2006
12/30/2006
Time
14:15
14:15
14:16
Tamb (°C)
15.8
16.1
15.0
Tref (°C)
30.1
29.6
29.9
Tm (°C)
20.2
22.3
23.4
Irradiance (W/m^2)
1006.2
1003.5
999.8
Isc (A)
8.40
8.41
8.37
Voc (V)
37.14
36.82
36.62
Imp (A)
7.55
7.53
7.44
Vmp (V)
28.19
27.90
27.86
Pm (W)
212.86
210.15
207.15
FF (%)
68.3
67.9
67.6
Explanation / Answer
In order to filter text, one has to use a text filtering tool such as awk. You can think of awk as a programming language of its own. But for the scope of this guide to using awk, we shall cover it as a simple command line filtering tool.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.