Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do I direct the output to a file named lab6.3.out? Here is the code echo \"P

ID: 3711972 • Letter: H

Question

How do I direct the output to a file named lab6.3.out? Here is the code

echo "Performance_Data";

IFS=$' '

for i in `cat data`;

do

   field1=`echo $i | cut -d' ' -f1`

   field2=`echo $i | cut -d' ' -f2`

   field3=`echo $i | cut -d' ' -f3`

   field4=`echo $i | cut -d' ' -f4`

   if [[ $field1 = D ]];

   then

   echo -e "Date " $field2

   fi

   if [[ $field1 = B ]];

   then

   echo -e "Tamb(C) " $field2

   fi

   if [[ $field1 = P ]];

   then

   echo -e "Tref(C) " $field2

   fi

   if [[ $field1 = Q ]];

   then

   echo -e "Tm(C) " $field2

   fi

   if [[ $field1 = R ]];

   then

   echo -e "Irradiance(W/m^2) " $field2

   fi

   if [[ $field1 = H ]];

   then

   echo -e "Isc(A) " $field2

   fi

   if [[ $field1 = O ]];

   then

   echo -e "Voc(V) " $field2

   fi

   if [[ $field1 = C ]];

   then

   echo -e "Imp(A) " $field2

   fi

   if [[ $field1 = K ]];

   then

   echo -e "Vmp(V) " $field2

   fi

   if [[ $field1 = W ]];

   then

   echo -e "Pm(W) " $field2

   fi

   if [[ $field1 = L ]];

   then

   echo -e "FF(%) " $field2

   fi

done

Explanation / Answer

echo "Performance_Data" >> lab6.3.out ;

IFS=$' '

for i in `cat data`;

do

   field1=`echo $i | cut -d' ' -f1`

   field2=`echo $i | cut -d' ' -f2`

   field3=`echo $i | cut -d' ' -f3`

   field4=`echo $i | cut -d' ' -f4`

   if [[ $field1 = D ]];

   then

   echo -e "Date " $field2   >> lab6.3.out

   fi

   if [[ $field1 = B ]];

   then

   echo -e "Tamb(C) " $field2 >> lab6.3.out

   fi

   if [[ $field1 = P ]];

   then

   echo -e "Tref(C) " $field2 >> lab6.3.out

   fi

   if [[ $field1 = Q ]];

   then

   echo -e "Tm(C) " $field2 >> lab6.3.out

   fi

   if [[ $field1 = R ]];

   then

   echo -e "Irradiance(W/m^2) " $field2   >> lab6.3.out

   fi

   if [[ $field1 = H ]];

   then

   echo -e "Isc(A) " $field2 >> lab6.3.out

   fi

   if [[ $field1 = O ]];

   then

   echo -e "Voc(V) " $field2 >> lab6.3.out

   fi

   if [[ $field1 = C ]];

   then

   echo -e "Imp(A) " $field2 >> lab6.3.out

   fi

   if [[ $field1 = K ]];

   then

   echo -e "Vmp(V) " $field2   >> lab6.3.out

   fi

   if [[ $field1 = W ]];

   then

   echo -e "Pm(W) " $field2   >> lab6.3.out

   fi

   if [[ $field1 = L ]];

   then

   echo -e "FF(%) " $field2 >> lab6.3.out

   fi

done


=====
Try it out, It should redirect the data into file

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote