Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This could give you your format:</p> <pre><code>#!/usr/bin/awk -f BEGIN { file1 = ARGV[1] file2 = ARGV[2] file3 = ARGV[3] getline &lt; file1 i = 0 while ((getline &lt; file1) &gt; 0) { r = $1 rollno_in_order[i++] = r t = $0 sub(/^[^[:blank:]]*[[:blank:]]*/, "", t) rollno_to_studentname[r] = t } getline &lt; file2 while ((getline &lt; file2) &gt; 0) { courseid = $1 t = $0 sub(/^[^[:blank:]]*[[:blank:]]*/, "", t) courseid_to_coursename[courseid] = t } i = 0 getline &lt; file3 while ((getline &lt; file3) &gt; 0) { i_to_courseid[i] = $2 i_to_grade[i] = $3 rollno_i_array[$1] = rollno_i_array[$1] i " " ++i } } END { for (i = 0; i in rollno_in_order; ++i) { r = rollno_in_order[i] printf("Roll No: %d\n", r) printf("Name: %s\n", rollno_to_studentname[r]) c = split(rollno_i_array[r], a, / */) for (j = 1; j &lt; c; ++j) { k = a[j] course_id = i_to_courseid[k] course_name = courseid_to_coursename[course_id] grade = i_to_grade[k] printf("CourseID: %s, CourseName: %s, Grade: %s\n", course_id, course_name, grade) | "sort" } close("sort") print "" } } </code></pre> <p>Running</p> <pre><code>awk -f script.awk -- file1 file2 file3 </code></pre> <p>Would give</p> <pre><code>Roll No: 1 Name: Student1 CourseID: BM13, CourseName: Linux, Grade: AB CourseID: CS11, CourseName: Discrete Mathematics, Grade: AB CourseID: CS12, CourseName: Business Communication, Grade: BC CourseID: MT15, CourseName: Business Management, Grade: BB Roll No: 2 Name: Student2 CourseID: BM13, CourseName: Linux, Grade: AB CourseID: CS11, CourseName: Discrete Mathematics, Grade: AA CourseID: CS12, CourseName: Business Communication, Grade: AA CourseID: MT15, CourseName: Business Management, Grade: AB Roll No: 3 Name: Student3 Roll No: 4 Name: Student4 </code></pre> <p>It's compatible with any standard awk.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload