Question
Need Help with Linux/UNIX shell scripting techniques: Please consider the following performance table: Performance Data Curve Name gge0001x gge0001y gge0001z Date 12/30/2006 12/30/2006 12/30/2006 Time
Need Help with Linux/UNIX shell scripting techniques:
Please consider the following performance table:
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 |
In the table above, gge001x, gge001y, and gge001z are 3 repeated measurements on panel id gge001.
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 seds 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started