Skip to content

Commit 905d331

Browse files
corrected search_terms.txt solution
1 parent 9c72a42 commit 905d331

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

exercises/Exercise_solutions.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,12 +985,16 @@ you
985985
is
986986
at
987987
988-
$ awk -v IGNORECASE=1 'NR==FNR{s[$0]; next} {for(k in s){if($0 ~ k && ++s[k]==(ARGC-2))
989-
print k}}' search_terms.txt jumbled.txt mixed_fs.txt secrets.txt table.txt
988+
$ awk -v IGNORECASE=1 'NR==FNR{s[$0]; next} {for(k in s) if($0 ~ k) a[k]}
989+
ENDFILE{for(k in a) s[k]++; delete a}
990+
END{for(k in s) if(s[k]==(ARGC-2)) print k}
991+
' search_terms.txt jumbled.txt mixed_fs.txt secrets.txt table.txt
990992
at
991993
row
992-
$ awk -v IGNORECASE=1 'NR==FNR{s[$0]; next} {for(k in s){if($0 ~ k && ++s[k]==(ARGC-2))
993-
print k}}' search_terms.txt addr.txt sample.txt
994+
$ awk -v IGNORECASE=1 'NR==FNR{s[$0]; next} {for(k in s) if($0 ~ k) a[k]}
995+
ENDFILE{for(k in a) s[k]++; delete a}
996+
END{for(k in s) if(s[k]==(ARGC-2)) print k}
997+
' search_terms.txt addr.txt sample.txt
994998
is
995999
you
9961000
hello

0 commit comments

Comments
 (0)